-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* trim trailing '-' sign * additional test * Update tags.go Here's what I recommend. * trimming * trimming after replacement test Co-authored-by: Aaron Alpar <55999015+aaron-kasten@users.noreply.github.com>
- Loading branch information
1 parent
897b8fc
commit 5a2294c
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package tags | ||
|
||
import ( | ||
"testing" | ||
|
||
. "gopkg.in/check.v1" | ||
) | ||
|
||
func Test(t *testing.T) { TestingT(t) } | ||
|
||
type TagsSuite struct{} | ||
|
||
var _ = Suite(&TagsSuite{}) | ||
|
||
func (s *TagsSuite) TestSanitizeValueForGCP(c *C) { | ||
for _, tc := range []struct { | ||
input string | ||
output string | ||
}{ | ||
{ | ||
input: "abcd", | ||
output: "abcd", | ||
}, | ||
{ | ||
input: "kasten__snapshot-wordpress-on-rbd-ceph-ns-2021-04-15t18-11-27z-abcd", | ||
output: "kasten__snapshot-wordpress-on-rbd-ceph-ns-2021-04-15t18-11-27z", | ||
}, | ||
{ | ||
input: "kasten__snapshot-wordpress-on-rbd-ceph-ns-", | ||
output: "kasten__snapshot-wordpress-on-rbd-ceph-ns", | ||
}, | ||
{ | ||
input: "kasten__snapshot-wordpress-on-rbd-ceph-ns---", | ||
output: "kasten__snapshot-wordpress-on-rbd-ceph-ns", | ||
}, | ||
{ | ||
input: "kasten__snapshot-wordpress! ?*()", | ||
output: "kasten__snapshot-wordpress", | ||
}, | ||
{ | ||
input: "kasten__snapshot-wordpress-on-rbd-ceph-ns-__", | ||
output: "kasten__snapshot-wordpress-on-rbd-ceph-ns", | ||
}, | ||
{ | ||
input: "kasten__snapshot-wordpress-on-rbd-ceph-ns__--", | ||
output: "kasten__snapshot-wordpress-on-rbd-ceph-ns", | ||
}, | ||
{ | ||
input: "ALLCAPS", | ||
output: "allcaps", | ||
}, | ||
} { | ||
out := SanitizeValueForGCP(tc.input) | ||
c.Assert(out, Equals, tc.output) | ||
} | ||
} |