Skip to content

Commit

Permalink
Update test to cover the default name
Browse files Browse the repository at this point in the history
With help from @phamann.
  • Loading branch information
fgsch committed Jul 20, 2020
1 parent c491592 commit 50360af
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions pkg/compute/compute_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestInit(t *testing.T) {
stdin string
wantError string
wantOutput []string
manifestIncludes string
manifestIncludes []string
}{
{
name: "no token",
Expand Down Expand Up @@ -120,7 +120,7 @@ func TestInit(t *testing.T) {
"Fetching package template...",
"Updating package manifest...",
},
manifestIncludes: `name = "test"`,
manifestIncludes: []string{`name = "test"`},
},
{
name: "with service",
Expand All @@ -140,7 +140,7 @@ func TestInit(t *testing.T) {
"Fetching package template...",
"Updating package manifest...",
},
manifestIncludes: `name = "test"`,
manifestIncludes: []string{`name = "test"`},
},
{
name: "with description",
Expand All @@ -158,7 +158,7 @@ func TestInit(t *testing.T) {
"Fetching package template...",
"Updating package manifest...",
},
manifestIncludes: `description = "test"`,
manifestIncludes: []string{`description = "test"`},
},
{
name: "with author",
Expand All @@ -176,7 +176,7 @@ func TestInit(t *testing.T) {
"Fetching package template...",
"Updating package manifest...",
},
manifestIncludes: `authors = ["[email protected]"]`,
manifestIncludes: []string{`authors = ["[email protected]"]`},
},
{
name: "with multiple authors",
Expand All @@ -194,7 +194,7 @@ func TestInit(t *testing.T) {
"Fetching package template...",
"Updating package manifest...",
},
manifestIncludes: `authors = ["[email protected]", "[email protected]"]`,
manifestIncludes: []string{`authors = ["[email protected]", "[email protected]"]`},
},

{
Expand Down Expand Up @@ -255,7 +255,10 @@ func TestInit(t *testing.T) {
CreateDomainFn: createDomainOK,
CreateBackendFn: createBackendOK,
},
manifestIncludes: `authors = ["[email protected]"]`,
manifestIncludes: []string{
`authors = ["[email protected]"]`,
`name = "fastly-build"`,
},
wantFiles: []string{
"Cargo.toml",
"fastly.toml",
Expand Down Expand Up @@ -322,12 +325,12 @@ func TestInit(t *testing.T) {
for _, s := range testcase.wantOutput {
testutil.AssertStringContains(t, buf.String(), s)
}
if testcase.manifestIncludes != "" {
content, err := ioutil.ReadFile(filepath.Join(rootdir, compute.ManifestFilename))
if err != nil {
t.Fatal(err)
}
testutil.AssertStringContains(t, string(content), testcase.manifestIncludes)
content, err := ioutil.ReadFile(filepath.Join(rootdir, compute.ManifestFilename))
if err != nil {
t.Fatal(err)
}
for _, s := range testcase.manifestIncludes {
testutil.AssertStringContains(t, string(content), s)
}
})
}
Expand Down

0 comments on commit 50360af

Please sign in to comment.