mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-30 10:47:14 -06:00
649095c602
* getproviders ParsePlatform: add check for invalid platform strings with too many parts The existing logic would not catch things like a platform string containing multiple underscores. I've added an explicit check for exactly 2 parts and some basic tests to prove it. * command/providers-lock: add tests This commit adds some simple tests for the providers lock command. While adding this test I noticed that there was a mis-copied error message, so I replaced that with a more specific message. I also added .terraform.lock.hcl to our gitignore for hopefully obvious reasons. getproviders.ParsePlatform: use parts in place of slice range, since it's available * command: Providers mirror tests The providers mirror command is already well tested in e2e tests, so this includes only the most absolutely basic test case.
37 lines
813 B
Go
37 lines
813 B
Go
package command
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/mitchellh/cli"
|
|
)
|
|
|
|
// More thorough tests for providers mirror can be found in the e2etest
|
|
func TestProvidersMirror(t *testing.T) {
|
|
// noop example
|
|
t.Run("noop", func(t *testing.T) {
|
|
c := &ProvidersMirrorCommand{}
|
|
code := c.Run([]string{"."})
|
|
if code != 0 {
|
|
t.Fatalf("wrong exit code. expected 0, got %d", code)
|
|
}
|
|
})
|
|
|
|
t.Run("missing arg error", func(t *testing.T) {
|
|
ui := new(cli.MockUi)
|
|
c := &ProvidersMirrorCommand{
|
|
Meta: Meta{Ui: ui},
|
|
}
|
|
code := c.Run([]string{})
|
|
if code != 1 {
|
|
t.Fatalf("wrong exit code. expected 1, got %d", code)
|
|
}
|
|
|
|
got := ui.ErrorWriter.String()
|
|
if !strings.Contains(got, "Error: No output directory specified") {
|
|
t.Fatalf("missing directory error from output, got:\n%s\n", got)
|
|
}
|
|
})
|
|
}
|