Skip to content

Commit

Permalink
Add EnsureDestination() test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcelo committed Jul 23, 2024
1 parent 7071b6f commit bf4d79e
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,45 @@ func (cs *ConfigSuite) Test_doAfterSave_addFunctionToList(c *C) {
c.Assert(found, Equals, true)
}

func (cs *ConfigSuite) Test_EnsureDestination_createsEncryptedConfigFile(c *C) {

a := &ApplicationConfig{
filename: "",
encryptedFile: true,
}

a.EnsureDestination()
fakeEncryptedConfigFile := filepath.Join(SystemConfigDir(), "wahay", "config.axx")

c.Assert(a.filename, Equals, fakeEncryptedConfigFile)
}

func (cs *ConfigSuite) Test_EnsureDestination_createsUnencryptedConfigFile(c *C) {

a := &ApplicationConfig{
filename: "",
encryptedFile: false,
}

a.EnsureDestination()
fakeUnencryptedConfigFile := filepath.Join(SystemConfigDir(), "wahay", "config.json")

c.Assert(a.filename, Equals, fakeUnencryptedConfigFile)
}

func (cs *ConfigSuite) Test_EnsureDestination_changesFileSuffixToAValidEncryptedSuffix(c *C) {

a := &ApplicationConfig{
filename: "config.json",
encryptedFile: true,
}

a.EnsureDestination()
fakeEncryptedConfigFile := filepath.Join(SystemConfigDir(), "wahay", "config.axx")

c.Assert(a.filename, Equals, fakeEncryptedConfigFile)
}

type MockKeySupplier struct {
mock.Mock
}
Expand Down

0 comments on commit bf4d79e

Please sign in to comment.