github.com/terraform-linters/tflint@v0.51.2-0.20240520175844-3750771571b6/terraform/module_mgr_test.go (about)

     1  package terraform
     2  
     3  import (
     4  	"path/filepath"
     5  	"testing"
     6  )
     7  
     8  func Test_moduleManifestPath(t *testing.T) {
     9  	tests := []struct {
    10  		name string
    11  		env  map[string]string
    12  		want string
    13  	}{
    14  		{
    15  			name: "default",
    16  			want: filepath.Join(".terraform", "modules", "modules.json"),
    17  		},
    18  		{
    19  			name: "TF_DATA_DIR",
    20  			env:  map[string]string{"TF_DATA_DIR": ".tfdata"},
    21  			want: filepath.Join(".tfdata", "modules", "modules.json"),
    22  		},
    23  	}
    24  
    25  	for _, test := range tests {
    26  		t.Run(test.name, func(t *testing.T) {
    27  			for k, v := range test.env {
    28  				t.Setenv(k, v)
    29  			}
    30  
    31  			got := moduleManifestPath()
    32  			if test.want != got {
    33  				t.Errorf("want: %s, got: %s", test.want, got)
    34  			}
    35  		})
    36  	}
    37  }