Skip to content

Commit

Permalink
Trim whitespace from console link text
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesnetherton committed Jul 13, 2020
1 parent ceaacae commit f8a9360
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/util/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func ConsoleLinkText(atlasMap *v1alpha1.AtlasMap) string {
name = strings.TrimPrefix(name, "atlasmap")
name = strings.TrimSuffix(name, "atlasmap")
name = strings.Title(name)
return "AtlasMap - " + name
return "AtlasMap - " + strings.TrimSpace(name)
}

// GetEnvVar gets the value of the given environment variable or returns a default value if it does not exist
Expand Down
9 changes: 9 additions & 0 deletions pkg/util/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ func TestConsoleLinkText(t *testing.T) {
},
}
assert.Equal(t, "AtlasMap - Test Name", ConsoleLinkText(atlasMap))

atlasMap.ObjectMeta.Name = "example-atlasmap"
assert.Equal(t, "AtlasMap - Example", ConsoleLinkText(atlasMap))

atlasMap.ObjectMeta.Name = "atlasmap-example"
assert.Equal(t, "AtlasMap - Example", ConsoleLinkText(atlasMap))

atlasMap.ObjectMeta.Name = "atlasmap-example-atlasmap"
assert.Equal(t, "AtlasMap - Example", ConsoleLinkText(atlasMap))
}

func TestGetEnvVar(t *testing.T) {
Expand Down

0 comments on commit f8a9360

Please sign in to comment.