Skip to content

Commit

Permalink
Fix issue with mock not taking effect
Browse files Browse the repository at this point in the history
  • Loading branch information
megablend committed Sep 15, 2023
1 parent 236dcf7 commit fcb95b2
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,28 @@ func TestNew_shouldReturnValidDetails(t *testing.T) {
}
}

func TestNew_shouldReadFromDefaultFolder_whenBasePathNotSet(t *testing.T) {
config, configErr := New()

require.NotNil(t, config)
assert.NoError(t, configErr)
assert.EqualValues(t, "private_key.pem", config.Jwt.PrivateKey)
assert.EqualValues(t, "public_key.pem", config.Jwt.PublicKey)
assert.EqualValues(t, "config/keys", config.Jwt.Directory)
assert.True(t, config.Jwt.GenerateKeys)
}

func TestNew_shouldReturnError_whenUnableToReadFile(t *testing.T) {
t.Skip("skipping because of monkey patch comaptiblity")
errMsg := "test error message while opening file"
defer monkey.UnpatchAll()
patchOsOpen(errMsg)

err := os.Setenv(BASE_PATH, "/path/to/config")

config, configErr := New()
config := &Config{}
configErr := config.InitConfig()

require.NoError(t, err)
require.Nil(t, config)
assert.Error(t, configErr)
assert.EqualValues(t, errMsg, configErr.Error())
}

0 comments on commit fcb95b2

Please sign in to comment.