github.com/graywolf-at-work-2/terraform-vendor@v1.4.5/internal/command/providers_mirror_test.go (about)

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