Skip to content

Commit

Permalink
adding test to parse storage
Browse files Browse the repository at this point in the history
  • Loading branch information
akshya96 committed Jun 9, 2022
1 parent 2cf1706 commit 4ae3afd
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
4 changes: 4 additions & 0 deletions command/server/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ func TestParseSeals(t *testing.T) {
testParseSeals(t)
}

func TestParseStorage(t *testing.T) {
testParseStorageTemplate(t)
}

func TestUnknownFieldValidation(t *testing.T) {
testUnknownFieldValidation(t)
}
Expand Down
44 changes: 44 additions & 0 deletions command/server/config_test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,49 @@ EOF
}
}

func testParseStorageTemplate(t *testing.T) {

This comment has been minimized.

Copy link
@ccapurso

ccapurso Jun 9, 2022

Contributor

Nice!

config, err := ParseConfig(`
storage "consul" {
disable_registration = false
path = "tmp/"
}
ha_storage "consul" {
tls_skip_verify = true
scheme = "http"
max_parallel = 128
}
`, "")
if err != nil {
t.Fatal(err)
}

expected := &Config{
Storage: &Storage{
Type: "consul",
Config: map[string]string{
"disable_registration": "false",
"path": "tmp/",
},
},
HAStorage: &Storage{
Type: "consul",
Config: map[string]string{
"tls_skip_verify": "true",
"scheme": "http",
"max_parallel": "128",
},
},
SharedConfig: &configutil.SharedConfig{},
}
config.Prune()
if diff := deep.Equal(config, expected); diff != nil {
t.Fatal(diff)
}
}

func testParseSeals(t *testing.T) {
config, err := LoadConfigFile("./test-fixtures/config_seals.hcl")
if err != nil {
Expand Down Expand Up @@ -1013,6 +1056,7 @@ func testLoadConfigFileLeaseMetrics(t *testing.T) {
Config: map[string]string{
"bar": "baz",
},

DisableClustering: true,
},

Expand Down

0 comments on commit 4ae3afd

Please sign in to comment.