github.com/opentofu/opentofu@v1.7.1/internal/command/providers_mirror_test.go (about) 1 // Copyright (c) The OpenTofu Authors 2 // SPDX-License-Identifier: MPL-2.0 3 // Copyright (c) 2023 HashiCorp, Inc. 4 // SPDX-License-Identifier: MPL-2.0 5 6 package command 7 8 import ( 9 "strings" 10 "testing" 11 12 "github.com/mitchellh/cli" 13 ) 14 15 // More thorough tests for providers mirror can be found in the e2etest 16 func TestProvidersMirror(t *testing.T) { 17 // noop example 18 t.Run("noop", func(t *testing.T) { 19 c := &ProvidersMirrorCommand{} 20 code := c.Run([]string{"."}) 21 if code != 0 { 22 t.Fatalf("wrong exit code. expected 0, got %d", code) 23 } 24 }) 25 26 t.Run("missing arg error", func(t *testing.T) { 27 ui := new(cli.MockUi) 28 c := &ProvidersMirrorCommand{ 29 Meta: Meta{Ui: ui}, 30 } 31 code := c.Run([]string{}) 32 if code != 1 { 33 t.Fatalf("wrong exit code. expected 1, got %d", code) 34 } 35 36 got := ui.ErrorWriter.String() 37 if !strings.Contains(got, "Error: No output directory specified") { 38 t.Fatalf("missing directory error from output, got:\n%s\n", got) 39 } 40 }) 41 }