Skip to content

Commit

Permalink
extension e2e: cleanup for readonly GOMODCACHE dir
Browse files Browse the repository at this point in the history
Signed-off-by: mathetake <[email protected]>
  • Loading branch information
mathetake committed Sep 22, 2020
1 parent 0bb6003 commit 6791785
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 5 deletions.
4 changes: 2 additions & 2 deletions pkg/cmd/extension/init/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
)

var (
// extension categories supported by the `init` command.
// SupportedCategories ... extension categories supported by the `init` command for each language.
SupportedCategories = map[string]options{
extension.LanguageRust.String(): {
{Value: extension.EnvoyHTTPFilter.String(), DisplayText: "HTTP Filter"},
Expand All @@ -38,7 +38,7 @@ var (
// {Value: extension.EnvoyNetworkFilter.String(), DisplayText: "Network Filter"},
},
}
// programming languages supported by the `init` command.
// SupportedLanguages ... programming languages supported by the `init` command.
SupportedLanguages = options{
{Value: extension.LanguageRust.String(), DisplayText: "Rust"},
{Value: extension.LanguageTinyGo.String(), DisplayText: "TinyGo"},
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/extension/init/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ type option struct {
}

// options represents an exhaustive list of valid configuration values.
type options []option
type options []*option

func (o options) Contains(value string) bool {
return o.IndexOf(value) >= 0
}

func (o options) ByValue(value string) *option {
if i := o.IndexOf(value); i >= 0 {
return &o[i]
return o[i]
}
return nil
}
Expand Down
8 changes: 7 additions & 1 deletion test/e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,14 @@ var _ = BeforeEach(func() {
})

var _ = AfterEach(func() {
GetEnvoy("extension clean")
if tempDir != "" {
Expect(os.RemoveAll(tempDir)).To(Succeed())
}
})

func cleanUpExtensionDir(dir string) {
Expect(os.Chdir(dir)).To(Succeed())
clean := GetEnvoy("extension clean")
_, _, err := clean.Exec()
Expect(err).To(Succeed())
}
1 change: 1 addition & 0 deletions test/e2e/getenvoy_extension_build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ var _ = Describe("getenvoy extension build", func() {
toolchain, err := toolchains.LoadToolchain(toolchains.Default, workspace)
Expect(err).NotTo(HaveOccurred())
Expect(toolchain).NotTo(BeNil())
cleanUpExtensionDir(outputDir)
},
testCases()...,
)
Expand Down
1 change: 1 addition & 0 deletions test/e2e/getenvoy_extension_examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ default
Use "getenvoy extension examples add --help" for more information on how to add one.
`))
cleanUpExtensionDir(outputDir)
},
testCases()...,
)
Expand Down
1 change: 1 addition & 0 deletions test/e2e/getenvoy_extension_init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ var _ = Describe("getenvoy extension init", func() {

By("verifying output directory")
VerifyOutputDir(given, outputDir)
cleanUpExtensionDir(outputDir)
},
testCases()...,
)
Expand Down
1 change: 1 addition & 0 deletions test/e2e/getenvoy_extension_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ var _ = Describe("getenvoy extension run", func() {
})
Expect(err).NotTo(HaveOccurred())
Expect(dumpFiles).To(ContainElements("config_dump.json", "stats.json"))
cleanUpExtensionDir(outputDir)
},
testCases()...,
)
Expand Down
1 change: 1 addition & 0 deletions test/e2e/getenvoy_extension_test_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ var _ = Describe("getenvoy extension test", func() {
// apparently, use of `-t` option in `docker run` causes stderr to be incorporated into stdout
Expect(stdout).NotTo(BeEmpty())
Expect(stderr).To(BeEmpty())
cleanUpExtensionDir(outputDir)
},
testCases()...,
)
Expand Down

0 comments on commit 6791785

Please sign in to comment.