aboutsummaryrefslogtreecommitdiff
path: root/pkg/config/config_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/config/config_test.go')
-rw-r--r--pkg/config/config_test.go56
1 files changed, 56 insertions, 0 deletions
diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go
new file mode 100644
index 0000000..c8cd887
--- /dev/null
+++ b/pkg/config/config_test.go
@@ -0,0 +1,56 @@
+// go:build unit
+package config
+
+import (
+ "strings"
+ "testing"
+
+ "github.com/google/go-cmp/cmp"
+)
+
+func TestConfig(t *testing.T) {
+ testCases := []struct {
+ name string
+ config string
+ expectedConfig *Configuration
+ }{
+ {
+ name: "minimal scan",
+ config: `scan "/srv/git"`,
+ expectedConfig: &Configuration{
+ Scan: &Scan{
+ Public: true,
+ Path: "/srv/git",
+ },
+ },
+ },
+ {
+ name: "complete scan",
+ config: `scan "/srv/git" {
+ public false
+}`,
+ expectedConfig: &Configuration{
+ Scan: &Scan{
+ Public: false,
+ Path: "/srv/git",
+ },
+ },
+ },
+ }
+
+ for _, tc := range testCases {
+ t.Run(tc.name, func(t *testing.T) {
+ r := strings.NewReader(tc.config)
+ config, err := Parse(r)
+ if err != nil {
+ t.Fatalf("Error parsing config %s", err.Error())
+ }
+
+ if diff := cmp.Diff(tc.expectedConfig, config); diff != "" {
+ t.Errorf("Wrong result given - wanted + got\n %s", diff)
+ }
+
+ })
+
+ }
+}