Skip to content

Commit

Permalink
finish testing create config
Browse files Browse the repository at this point in the history
  • Loading branch information
qrkourier committed Mar 8, 2024
1 parent a1ea703 commit fce47bc
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion ziti/cmd/create/create_config_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ func TestCreateConfigControllerTemplateValues(t *testing.T) {
".Controller.Ctrl.BindAddress",
".Controller.Ctrl.AdvertisedAddress",
".Controller.Ctrl.AdvertisedPort",
".Controller.Database.DatabaseFile",
".Controller.EdgeApi.Address",
".Controller.EdgeApi.Port",
".Controller.EdgeEnrollment.SigningCert",
Expand All @@ -164,6 +165,7 @@ func TestCreateConfigControllerTemplateValues(t *testing.T) {
&data.Controller.Ctrl.BindAddress,
&data.Controller.Ctrl.AdvertisedAddress,
&data.Controller.Ctrl.AdvertisedPort,
&data.Controller.Database.DatabaseFile,
&data.Controller.EdgeApi.Address,
&data.Controller.EdgeApi.Port,
&data.Controller.EdgeEnrollment.SigningCert,
Expand Down Expand Up @@ -283,6 +285,7 @@ func TestCtrlConfigDefaultsWhenUnset(t *testing.T) {
assert.Equal(t, expectedValue, data.Controller.Database.DatabaseFile)
})

// db:
t.Run("TestDatabaseFileConfig", func(t *testing.T) {
expectedValue := cmdhelper.GetZitiHome() + "/" + constants.DefaultCtrlDatabaseFile

Expand Down Expand Up @@ -454,10 +457,11 @@ func TestCtrlConfigDefaultsWhenUnset(t *testing.T) {
})
}

func TestCtrlConfigDefaultsWhenBlank(t *testing.T) {
func TestCtrlConfigDefaultsWhenEmpty(t *testing.T) {
keys := map[string]string{
"ZITI_PKI_CTRL_CERT": "",
"ZITI_CTRL_EDGE_ADVERTISED_ADDRESS": "",
"ZITI_CTRL_DATABASE_FILE": "",
"ZITI_HOME": "",
}
// run the config
Expand Down Expand Up @@ -489,6 +493,19 @@ func TestCtrlConfigDefaultsWhenBlank(t *testing.T) {
assert.Equal(t, expectedValue, ctrlConfig.Identity.Ca)
})

// db:
t.Run("TestDatabaseFileEnv", func(t *testing.T) {
expectedValue := constants.DefaultCtrlDatabaseFile

assert.Equal(t, expectedValue, data.Controller.Database.DatabaseFile)
})

t.Run("TestDatabaseFileConfig", func(t *testing.T) {
expectedValue := cmdhelper.GetZitiHome() + "/" + constants.DefaultCtrlDatabaseFile

assert.Equal(t, expectedValue, ctrlConfig.Db)
})

// ctrl:
t.Run("TestBindAddress", func(t *testing.T) {
expectedValue := testDefaultCtrlBindAddress
Expand Down

0 comments on commit fce47bc

Please sign in to comment.