8000 Remove flaky test logic. by Integralist · Pull Request #249 · fastly/cli · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Remove flaky test logic. #249

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff 8000 view
28 changes: 2 additions & 26 deletions pkg/compute/manifest/manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ func TestManifest(t *testing.T) {
manifest string
valid bool
expectedError error
checkRef bool
}{
"valid: semver": {
manifest: "fastly-valid-semver.toml",
Expand All @@ -31,7 +30,6 @@ func TestManifest(t *testing.T) {
"invalid: missing manifest_version causes default to be set": {
manifest: "fastly-invalid-missing-version.toml",
valid: true,
checkRef: true,
},
"invalid: manifest_version as a section causes default to be set": {
manifest: "fastly-invalid-section-version.toml",
Expand Down Expand Up @@ -96,28 +94,6 @@ func TestManifest(t *testing.T) {
if err != nil {
t.Fatal(err)
}

// NOTE: we only assign checkRef to one of the invalid test cases, even
// though in practice the reference link will be added anytime a write
// operation is executed on the manifest file, because as far as the
// test suite is concerned it's constrained by the use of `once.Do()`
// at the package level of the manifest package.
//
// This is validating the write operation called when the
// manifest_version is invalid. We have a separate test function for
// validating the function that prepends the reference more explicitly.
if tc.checkRef {
b, err := os.ReadFile(path)
if err != nil {
t.Fatal(err)
}

content := string(b)

if !strings.Contains(content, SpecIntro) || !strings.Contains(content, SpecURL) {
t.Fatal("missing fastly.toml specification reference link")
}
}
} else {
// otherwise if we expect the manifest to be invalid/unrecognised then
// the error should match our expectations.
Expand All @@ -132,14 +108,14 @@ func TestManifest(t *testing.T) {
func TestManifestPrepend(t *testing.T) {
prefix := filepath.Join("../", "testdata", "init")

// NOTE: the fixture file "fastly-invalid-missing-version.toml" will be
// NOTE: the fixture file "fastly-missing-spec-url.toml" will be
// overwritten by the test as the internal logic is supposed to add into the
// manifest a reference to the fastly.toml specification.
//
// To ensure future test runs complete successfully we do an initial read of
// the data and then write it back out when the tests have completed.

fpath := "fastly-invalid-missing-version.toml"
fpath := "fastly-missing-spec-url.toml"

path, err := filepath.Abs(filepath.Join(prefix, fpath))
if err != nil {
Expand Down
5 changes: 5 additions & 0 deletions pkg/compute/testdata/init/fastly-missing-spec-url.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
manifest_version = 1
name = "Default Rust template"
description = "Default package template for Rust based edge compute projects."
authors = ["phamann <patrick@fastly.com>"]
language = "rust"
0