github.com/opentofu/opentofu@v1.7.1/internal/command/plugins_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  	"os"
    10  	"reflect"
    11  	"testing"
    12  )
    13  
    14  func TestPluginPath(t *testing.T) {
    15  	td := testTempDir(t)
    16  	defer os.RemoveAll(td)
    17  	defer testChdir(t, td)()
    18  
    19  	pluginPath := []string{"a", "b", "c"}
    20  
    21  	m := Meta{}
    22  	if err := m.storePluginPath(pluginPath); err != nil {
    23  		t.Fatal(err)
    24  	}
    25  
    26  	restoredPath, err := m.loadPluginPath()
    27  	if err != nil {
    28  		t.Fatal(err)
    29  	}
    30  
    31  	if !reflect.DeepEqual(pluginPath, restoredPath) {
    32  		t.Fatalf("expected plugin path %#v, got %#v", pluginPath, restoredPath)
    33  	}
    34  }
    35  
    36  func TestInternalProviders(t *testing.T) {
    37  	m := Meta{}
    38  	internal := m.internalProviders()
    39  	tfProvider, err := internal["terraform"]()
    40  	if err != nil {
    41  		t.Fatal(err)
    42  	}
    43  
    44  	schema := tfProvider.GetProviderSchema()
    45  	_, found := schema.DataSources["terraform_remote_state"]
    46  	if !found {
    47  		t.Errorf("didn't find terraform_remote_state in internal \"terraform\" provider")
    48  	}
    49  }