This repository has been archived by the owner on Jun 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 48
pkg/terraform: improvements #1027
Merged
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c095660
pkg/terraform: handle error from os.RemoveAll() in tests
invidian 42042e1
pkg/terraform: convert e2e test to use exported API
invidian bc749c5
pkg/terraform: move e2e tests to separate file
invidian 5c31626
pkg/terraform: test requiredVersion const in unit tests
invidian ef514c5
pkg/terraform: make error messages from checkVersion more useful
invidian 647cc34
pkg/terraform: add unit tests for checkVersion()
invidian 300075b
pkg/terraform: add missing license header to e2e test file
invidian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 11 additions & 5 deletions
16
pkg/terraform/executor_test.go → pkg/terraform/executor_e2e_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,34 @@ | ||
//+build e2e | ||
invidian marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should e2e tests sit in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO, those are package-scoped tests, so I think it's fine if they sit in this directory. They are marked as |
||
|
||
package terraform | ||
package terraform_test | ||
|
||
import ( | ||
"io/ioutil" | ||
"os" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/kinvolk/lokomotive/pkg/terraform" | ||
) | ||
|
||
func executor(t *testing.T) *Executor { | ||
func executor(t *testing.T) *terraform.Executor { | ||
tmpDir, err := ioutil.TempDir("", "lokoctl-tests-") | ||
if err != nil { | ||
t.Fatalf("Creating tmp dir should succeed, got: %v", err) | ||
} | ||
|
||
defer os.RemoveAll(tmpDir) | ||
t.Cleanup(func() { | ||
if err := os.RemoveAll(tmpDir); err != nil { | ||
t.Logf("Removing directory %q: %v", tmpDir, err) | ||
} | ||
}) | ||
|
||
conf := Config{ | ||
conf := terraform.Config{ | ||
Verbose: false, | ||
WorkingDir: tmpDir, | ||
} | ||
|
||
ex, err := NewExecutor(conf) | ||
ex, err := terraform.NewExecutor(conf) | ||
if err != nil { | ||
t.Fatalf("Creating new executor should succeed, got: %v", err) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright 2020 The Lokomotive Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package terraform | ||
invidian marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/go-version" | ||
) | ||
|
||
func TestRequiredVersion(t *testing.T) { | ||
if _, err := version.NewConstraint(requiredVersion); err != nil { | ||
t.Fatalf("requiredVersion const must be valid version constraint, got: %v", err) | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can log it in debug mode? So we don't lose track of it altogether.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? It is covered by unit tests, running exactly the same code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's best to panic in such case, if this error should be found during development itself.