Skip to content

Commit

Permalink
correcting for hard coded copy.
Browse files Browse the repository at this point in the history
  • Loading branch information
Caesonia committed Oct 17, 2024
1 parent cf12381 commit 50da8ac
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions common/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 69,7 @@ func TestNewConfig(t *testing.T) {

jsonString, err := config.ToJSON()
require.NoError(t, err)
assert.Equal(t, expectedConfigJson, jsonString)
assert.Equal(t, GetExpectedConfigJson(), jsonString)
}

func TestConfigBucketQualifier(t *testing.T) {
Expand Down Expand Up @@ -145,6 145,9 @@ func TestHTTPScheme(t *testing.T) {
assert.Equal(t, "https", config.HTTPScheme())
}

// expectedConfigJson contains expected config JSON.
// Don't use this directly. Use GetExpectedConfigJSON instead
// because it substitutes '%s' with correct path.
var expectedConfigJson = `{
"Cookies": {
"Secure": {},
Expand All @@ -166,7 169,7 @@ var expectedConfigJson = `{
},
"EnvName": "test",
"Logging": {
"File": "/home/diamond/tmp/logs/registry_test.log",
"File": "%s",
"Level": 0,
"LogCaller": false,
"LogToConsole": false,
Expand Down Expand Up @@ -206,3 209,11 @@ var expectedConfigJson = `{
"MaintenanceMode": false,
"EmailServiceType": "SMTP"
}`

// GetExpectedConfigJson returns the expected config settings
// in JSON format. Note that it constructs the expected log file
// path based on the current user's home directory.
func GetExpectedConfigJson() string {
logFile, _ := common.ExpandTilde("~/tmp/logs/registry_test.log")
return fmt.Sprintf(expectedConfigJson, logFile)
}

0 comments on commit 50da8ac

Please sign in to comment.