Rediscover Go settings only when Go work needs them
This commit is contained in:
@@ -320,9 +320,6 @@ func TestOwnerReusesSettingsUntilInheritedEnvironmentChanges(t *testing.T) {
|
||||
|
||||
cache := filepath.Join(t.TempDir(), "changed-cache")
|
||||
t.Setenv("GOCACHE", cache)
|
||||
if err := owner.Refresh(context.Background()); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
third, err := owner.Acquire(context.Background())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -332,6 +329,24 @@ func TestOwnerReusesSettingsUntilInheritedEnvironmentChanges(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestOwnerAcceptsGoConfigurationWithoutReadableSnapshot(t *testing.T) {
|
||||
clearGoSettings(t)
|
||||
t.Setenv("GOENV", t.TempDir())
|
||||
directory := t.TempDir()
|
||||
if _, err := New(context.Background(), directory); err != nil {
|
||||
t.Fatalf("underlying Go discovery rejected fixture: %v", err)
|
||||
}
|
||||
owner := NewOwner(directory)
|
||||
first, err := owner.Acquire(context.Background())
|
||||
if err != nil {
|
||||
t.Fatalf("owner added a snapshot prerequisite: %v", err)
|
||||
}
|
||||
second, err := owner.Acquire(context.Background())
|
||||
if err != nil || first == second {
|
||||
t.Fatalf("unavailable snapshot should rediscover on demand: first=%p second=%p error=%v", first, second, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestOwnerRefreshesWhenPersistentSettingsChange(t *testing.T) {
|
||||
clearGoSettings(t)
|
||||
firstCache := filepath.Join(t.TempDir(), "first-cache")
|
||||
@@ -355,9 +370,6 @@ func TestOwnerRefreshesWhenPersistentSettingsChange(t *testing.T) {
|
||||
t.Fatalf("initial GOCACHE = %q, want %q", first.settings["GOCACHE"], firstCache)
|
||||
}
|
||||
writeSettings(secondCache)
|
||||
if err := owner.Refresh(context.Background()); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
second, err := owner.Acquire(context.Background())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
Reference in New Issue
Block a user