github.com/opentofu/opentofu@v1.7.1/internal/plugin/discovery/get_cache_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 discovery
     7  
     8  import (
     9  	"testing"
    10  )
    11  
    12  func TestLocalPluginCache(t *testing.T) {
    13  	cache := NewLocalPluginCache("testdata/plugin-cache")
    14  
    15  	foo1Path := cache.CachedPluginPath("provider", "foo", VersionStr("v0.0.1").MustParse())
    16  	if foo1Path == "" {
    17  		t.Errorf("foo v0.0.1 not found; should have been found")
    18  	}
    19  
    20  	foo2Path := cache.CachedPluginPath("provider", "foo", VersionStr("v0.0.2").MustParse())
    21  	if foo2Path != "" {
    22  		t.Errorf("foo v0.0.2 found at %s; should not have been found", foo2Path)
    23  	}
    24  
    25  	baz1Path := cache.CachedPluginPath("provider", "baz", VersionStr("v0.0.1").MustParse())
    26  	if baz1Path != "" {
    27  		t.Errorf("baz v0.0.1 found at %s; should not have been found", baz1Path)
    28  	}
    29  
    30  	baz2Path := cache.CachedPluginPath("provider", "baz", VersionStr("v0.0.2").MustParse())
    31  	if baz1Path != "" {
    32  		t.Errorf("baz v0.0.2 found at %s; should not have been found", baz2Path)
    33  	}
    34  }