mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-28 18:01:01 -06:00
fb58f9e6d2
There is a race between the MockSource and ShutdownCh which sometimes causes this test to fail. Add a HangingSource implementation of Source which hangs until the context is cancelled, so that there is always time for a user-initiated shutdown to trigger the cancellation code path under test.
30 lines
770 B
Go
30 lines
770 B
Go
package getproviders
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/hashicorp/terraform/internal/addrs"
|
|
)
|
|
|
|
// HangingSource is an implementation of Source which hangs until the given
|
|
// context is cancelled. This is useful only for unit tests of user-controlled
|
|
// cancels.
|
|
type HangingSource struct {
|
|
}
|
|
|
|
var _ Source = (*HangingSource)(nil)
|
|
|
|
func (s *HangingSource) AvailableVersions(ctx context.Context, provider addrs.Provider) (VersionList, Warnings, error) {
|
|
<-ctx.Done()
|
|
return nil, nil, nil
|
|
}
|
|
|
|
func (s *HangingSource) PackageMeta(ctx context.Context, provider addrs.Provider, version Version, target Platform) (PackageMeta, error) {
|
|
<-ctx.Done()
|
|
return PackageMeta{}, nil
|
|
}
|
|
|
|
func (s *HangingSource) ForDisplay(provider addrs.Provider) string {
|
|
return "hanging source"
|
|
}
|