fix unit tests

This commit is contained in:
Brad Rydzewski
2019-12-09 14:07:24 -08:00
parent 2e48cd1b3b
commit f746e00e7c
4 changed files with 11 additions and 9 deletions

View File

@@ -32,7 +32,7 @@ func TestClone(t *testing.T) {
Secret: secret.Static(nil), Secret: secret.Static(nil),
Environ: provider.Static(nil), Environ: provider.Static(nil),
} }
args := Args{ args := runtime.CompilerArgs{
Repo: &drone.Repo{}, Repo: &drone.Repo{},
Build: &drone.Build{}, Build: &drone.Build{},
Stage: &drone.Stage{}, Stage: &drone.Stage{},
@@ -57,7 +57,7 @@ func TestClone(t *testing.T) {
}, },
}, },
} }
got := c.Compile(nocontext, args) got := c.Compile(nocontext, args).(*engine.Spec)
ignore := cmpopts.IgnoreFields(engine.Step{}, "Envs", "Labels") ignore := cmpopts.IgnoreFields(engine.Step{}, "Envs", "Labels")
if diff := cmp.Diff(got.Steps, want, ignore); len(diff) != 0 { if diff := cmp.Diff(got.Steps, want, ignore); len(diff) != 0 {
t.Errorf(diff) t.Errorf(diff)
@@ -70,7 +70,7 @@ func TestCloneDisable(t *testing.T) {
Registry: registry.Static(nil), Registry: registry.Static(nil),
Secret: secret.Static(nil), Secret: secret.Static(nil),
} }
args := Args{ args := runtime.CompilerArgs{
Repo: &drone.Repo{}, Repo: &drone.Repo{},
Build: &drone.Build{}, Build: &drone.Build{},
Stage: &drone.Stage{}, Stage: &drone.Stage{},
@@ -79,7 +79,7 @@ func TestCloneDisable(t *testing.T) {
Manifest: &manifest.Manifest{}, Manifest: &manifest.Manifest{},
Pipeline: &resource.Pipeline{Clone: manifest.Clone{Disable: true}}, Pipeline: &resource.Pipeline{Clone: manifest.Clone{Disable: true}},
} }
got := c.Compile(nocontext, args) got := c.Compile(nocontext, args).(*engine.Spec)
if len(got.Steps) != 0 { if len(got.Steps) != 0 {
t.Errorf("Expect no clone step added when disabled") t.Errorf("Expect no clone step added when disabled")
} }

View File

@@ -107,7 +107,7 @@ func TestCompile_Secrets(t *testing.T) {
"my_username": "octocat", "my_username": "octocat",
}), }),
} }
args := Args{ args := runtime.CompilerArgs{
Repo: &drone.Repo{}, Repo: &drone.Repo{},
Build: &drone.Build{}, Build: &drone.Build{},
Stage: &drone.Stage{}, Stage: &drone.Stage{},
@@ -118,7 +118,7 @@ func TestCompile_Secrets(t *testing.T) {
Secret: secret.Static(nil), Secret: secret.Static(nil),
} }
ir := compiler.Compile(nocontext, args) ir := compiler.Compile(nocontext, args).(*engine.Spec)
got := ir.Steps[0].Secrets got := ir.Steps[0].Secrets
want := []*engine.Secret{ want := []*engine.Secret{
{ {
@@ -169,7 +169,7 @@ func testCompile(t *testing.T, source, golden string) *engine.Spec {
"my_username": "octocat", "my_username": "octocat",
}), }),
} }
args := Args{ args := runtime.CompilerArgs{
Repo: &drone.Repo{}, Repo: &drone.Repo{},
Build: &drone.Build{Target: "master"}, Build: &drone.Build{Target: "master"},
Stage: &drone.Stage{}, Stage: &drone.Stage{},
@@ -203,7 +203,7 @@ func testCompile(t *testing.T, source, golden string) *engine.Spec {
t.Errorf(diff) t.Errorf(diff)
} }
return got return got.(*engine.Spec)
} }
func dump(v interface{}) { func dump(v interface{}) {

2
go.mod
View File

@@ -12,7 +12,7 @@ require (
github.com/drone/drone-go v1.1.1-0.20191119212130-1d2e07e87e79 github.com/drone/drone-go v1.1.1-0.20191119212130-1d2e07e87e79
github.com/drone/drone-runtime v1.1.0 github.com/drone/drone-runtime v1.1.0
github.com/drone/envsubst v1.0.2 github.com/drone/envsubst v1.0.2
github.com/drone/runner-go v1.4.1-0.20191206210533-80bb9688cb0c github.com/drone/runner-go v1.5.0
github.com/drone/signal v1.0.0 github.com/drone/signal v1.0.0
github.com/ghodss/yaml v1.0.0 github.com/ghodss/yaml v1.0.0
github.com/golang/mock v1.3.1 github.com/golang/mock v1.3.1

2
go.sum
View File

@@ -56,6 +56,8 @@ github.com/drone/runner-go v1.4.1-0.20191206204642-f16a481b8b8f h1:TC1w5LWTOEbba
github.com/drone/runner-go v1.4.1-0.20191206204642-f16a481b8b8f/go.mod h1:ZIhsNU4EHG7R7J+OXeXuwwAxlxOBYLCc0gCkbbhWb/o= github.com/drone/runner-go v1.4.1-0.20191206204642-f16a481b8b8f/go.mod h1:ZIhsNU4EHG7R7J+OXeXuwwAxlxOBYLCc0gCkbbhWb/o=
github.com/drone/runner-go v1.4.1-0.20191206210533-80bb9688cb0c h1:T3CIdRKiTiaNbInLmtPOoY/9BNUPaL2ipBr2jHzaJsE= github.com/drone/runner-go v1.4.1-0.20191206210533-80bb9688cb0c h1:T3CIdRKiTiaNbInLmtPOoY/9BNUPaL2ipBr2jHzaJsE=
github.com/drone/runner-go v1.4.1-0.20191206210533-80bb9688cb0c/go.mod h1:ZIhsNU4EHG7R7J+OXeXuwwAxlxOBYLCc0gCkbbhWb/o= github.com/drone/runner-go v1.4.1-0.20191206210533-80bb9688cb0c/go.mod h1:ZIhsNU4EHG7R7J+OXeXuwwAxlxOBYLCc0gCkbbhWb/o=
github.com/drone/runner-go v1.5.0 h1:4cgQn+ZIf9TKHQpAF8wC06knqSULZ8T46tFxPZ5ADs0=
github.com/drone/runner-go v1.5.0/go.mod h1:ZIhsNU4EHG7R7J+OXeXuwwAxlxOBYLCc0gCkbbhWb/o=
github.com/drone/signal v1.0.0 h1:NrnM2M/4yAuU/tXs6RP1a1ZfxnaHwYkd0kJurA1p6uI= github.com/drone/signal v1.0.0 h1:NrnM2M/4yAuU/tXs6RP1a1ZfxnaHwYkd0kJurA1p6uI=
github.com/drone/signal v1.0.0/go.mod h1:S8t92eFT0g4WUgEc/LxG+LCuiskpMNsG0ajAMGnyZpc= github.com/drone/signal v1.0.0/go.mod h1:S8t92eFT0g4WUgEc/LxG+LCuiskpMNsG0ajAMGnyZpc=
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=