break out repo split and add unit test
This commit is contained in:
19
cmd/drone-docker-ecr/main_test.go
Normal file
19
cmd/drone-docker-ecr/main_test.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package main
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestGetRepoName(t *testing.T) {
|
||||
// map full repo path to expected repo name
|
||||
repos := map[string]string{
|
||||
"000000000000.dkr.ecr.us-east-1.amazonaws.com/repo": "repo",
|
||||
"000000000000.dkr.ecr.us-east-1.amazonaws.com/namespace/repo": "namespace/repo",
|
||||
"000000000000.dkr.ecr.us-east-1.amazonaws.com/namespace/namespace/repo": "namespace/namespace/repo",
|
||||
}
|
||||
|
||||
for repo, name := range repos {
|
||||
splitName := getRepoName(repo)
|
||||
if splitName != name {
|
||||
t.Errorf("%s is not equal to %s.", splitName, name)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user