2018-02-10 17:41:07 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import "testing"
|
|
|
|
|
2018-02-10 23:41:49 +01:00
|
|
|
func TestTrimHostname(t *testing.T) {
|
|
|
|
registry := "000000000000.dkr.ecr.us-east-1.amazonaws.com"
|
2018-02-10 17:41:07 +01:00
|
|
|
// map full repo path to expected repo name
|
|
|
|
repos := map[string]string{
|
2018-02-10 23:41:49 +01:00
|
|
|
registry + "/repo": "repo",
|
|
|
|
registry + "/namespace/repo": "namespace/repo",
|
|
|
|
registry + "/namespace/namespace/repo": "namespace/namespace/repo",
|
2018-02-10 17:41:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
for repo, name := range repos {
|
2018-02-10 23:41:49 +01:00
|
|
|
splitName := trimHostname(repo, registry)
|
2018-02-10 17:41:07 +01:00
|
|
|
if splitName != name {
|
|
|
|
t.Errorf("%s is not equal to %s.", splitName, name)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|