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.go82
1 files changed, 77 insertions, 5 deletions
diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go
index 7afbaef..9109ecb 100644
--- a/pkg/config/config_test.go
+++ b/pkg/config/config_test.go
@@ -19,21 +19,94 @@ func TestFileParsing(t *testing.T) {
config: `scan "/srv/git"`,
expectedConfig: &configuration{
Scan: &scan{
- Public: true,
+ Public: false,
Path: "/srv/git",
},
+ Repositories: []*GitRepositoryConfiguration{},
},
},
{
name: "complete scan",
- config: `scan "/srv/git" {
- public false
+ config: `
+scan "/srv/git" {
+ public true
}`,
expectedConfig: &configuration{
Scan: &scan{
- Public: false,
+ Public: true,
Path: "/srv/git",
},
+ Repositories: []*GitRepositoryConfiguration{},
+ },
+ },
+ {
+ name: "minimal repository",
+ config: `repository /srv/git/cerrado.git`,
+ expectedConfig: &configuration{
+ Scan: defaultScan(),
+ Repositories: []*GitRepositoryConfiguration{
+ {
+ Name: "cerrado.git",
+ Path: "/srv/git/cerrado.git",
+ Description: "",
+ Public: false,
+ },
+ },
+ },
+ },
+ {
+ name: "complete repository",
+ config: `
+repository /srv/git/cerrado.git {
+ name cerrado
+ description "Single person forge"
+ public true
+}`,
+ expectedConfig: &configuration{
+ Scan: defaultScan(),
+ Repositories: []*GitRepositoryConfiguration{
+ {
+ Name: "cerrado",
+ Path: "/srv/git/cerrado.git",
+ Description: "Single person forge",
+ Public: true,
+ },
+ },
+ },
+ },
+ {
+ name: "complete",
+ config: `
+scan "/srv/git" {
+ public true
+}
+
+repository /srv/git/linux.git
+
+repository /srv/git/cerrado.git {
+ name cerrado
+ description "Single person forge"
+ public true
+}`,
+ expectedConfig: &configuration{
+ Scan: &scan{
+ Public: true,
+ Path: "/srv/git",
+ },
+ Repositories: []*GitRepositoryConfiguration{
+ {
+ Name: "linux.git",
+ Path: "/srv/git/linux.git",
+ Description: "",
+ Public: false,
+ },
+ {
+ Name: "cerrado",
+ Path: "/srv/git/cerrado.git",
+ Description: "Single person forge",
+ Public: true,
+ },
+ },
},
},
}
@@ -49,7 +122,6 @@ func TestFileParsing(t *testing.T) {
if diff := cmp.Diff(tc.expectedConfig, config); diff != "" {
t.Errorf("Wrong result given - wanted + got\n %s", diff)
}
-
})
}