func (s) TestStoreWithSingleProviderWithSharing(t *testing.T) {
	prov1, fp1 := makeProvider(t, fakeProvider1Name, fakeConfig)
	prov2, _ := makeProvider(t, fakeProvider1Name, fakeConfig)

	// Push key materials into the fake provider1.
	wantKM, err := loadKeyMaterials()
	if err != nil {
		t.Fatal(err)
	}
	fp1.kmCh <- wantKM

	// Get key materials from the fake provider2 and compare it to the ones we
	// pushed above.
	ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
	defer cancel()
	gotKM, err := prov2.KeyMaterial(ctx)
	if err != nil {
		t.Fatalf("provider.KeyMaterial() = %v", err)
	}
	if !reflect.DeepEqual(gotKM, wantKM) {
		t.Fatalf("provider.KeyMaterial() = %+v, want %+v", gotKM, wantKM)
	}

	// Close the provider1 and retry the KeyMaterial() call on prov2, and expect
	// it to succeed.
	prov1.Close()
	if _, err := prov2.KeyMaterial(ctx); err != nil {
		t.Fatalf("provider.KeyMaterial() = %v", err)
	}

	prov2.Close()
	if _, err := prov2.KeyMaterial(ctx); err != errProviderClosed {
		t.Fatalf("provider.KeyMaterial() = %v, wantErr: %v", err, errProviderClosed)
	}
}
// TestStoreWithSingleProviderWithSharing creates multiple instances of the same
// type of provider through the store (and expects the store's sharing mechanism
// to kick in) and calls methods on it.
TestStoreWithSingleProviderWithSharing creates multiple instances of the same
type of provider through the store (and expects the store's sharing mechanism
to kick in) and calls methods on it.
// TestStoreWithSingleProviderWithSharing creates multiple instances of the same // type of provider through the store ( and expects the store ' s sharing mechanism // to kick in ) and calls methods on it .
func (s) TestStoreWithSingleProviderWithSharing(t *testing.T) {
	prov1, fp1 := makeProvider(t, fakeProvider1Name, fakeConfig)
	prov2, _ := makeProvider(t, fakeProvider1Name, fakeConfig)
	wantKM, err := loadKeyMaterials()
	if err != nil {
		t.Fatal(err)
	}
	fp1.kmCh <- wantKM
	ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
	defer cancel()
	gotKM, err := prov2.KeyMaterial(ctx)
	if err != nil {
		t.Fatalf("provider.KeyMaterial() = %v", err)
	}
	if !reflect.DeepEqual(gotKM, wantKM) {
		t.Fatalf("provider.KeyMaterial() = %+v, want %+v", gotKM, wantKM)
	}
	prov1.Close()
	if _, err := prov2.KeyMaterial(ctx); err != nil {
		t.Fatalf("provider.KeyMaterial() = %v", err)
	}
	prov2.Close()
	if _, err := prov2.KeyMaterial(ctx); err != errProviderClosed {
		t.Fatalf("provider.KeyMaterial() = %v, wantErr: %v", err, errProviderClosed)
	}
}
func ( s ) TestStoreWithSingleProviderWithSharing ( t * testing . T ) { prov1 , fp1 := makeProvider ( t , fakeProvider1Name , fakeConfig ) prov2 , _ := makeProvider ( t , fakeProvider1Name , fakeConfig ) wantKM , err := loadKeyMaterials ( ) if err != nil { t . Fatal ( err ) } fp1 . kmCh <- wantKM ctx , cancel := context . WithTimeout ( context . Background ( ) , defaultTestTimeout ) defer cancel ( ) gotKM , err := prov2 . KeyMaterial ( ctx ) if err != nil { t . Fatalf ( " " , err ) } if ! reflect . DeepEqual ( gotKM , wantKM ) { t . Fatalf ( " " , gotKM , wantKM ) } prov1 . Close ( ) if _ , err := prov2 . KeyMaterial ( ctx ) ; err != nil { t . Fatalf ( " " , err ) } prov2 . Close ( ) if _ , err := prov2 . KeyMaterial ( ctx ) ; err != errProviderClosed { t . Fatalf ( " " , err , errProviderClosed ) } }
TestStoreWithSingleProviderWithSharing creates multiple instances of the same
type of provider through the store (and expects the store's sharing mechanism
to kick in) and calls methods on it.
TestStoreWithSingleProviderWithSharing creates multiple instances of the same type of provider through the store ( and expects the store ' s sharing mechanism to kick in ) and calls methods on it .
// Push key materials into the fake provider1. // Get key materials from the fake provider2 and compare it to the ones we // pushed above. // Close the provider1 and retry the KeyMaterial() call on prov2, and expect // it to succeed.