func (s) TestStoreWithMultipleProviders(t *testing.T) {
	prov1, fp1 := makeProvider(t, fakeProvider1Name, fakeConfig)
	prov2, fp2 := makeProvider(t, fakeProvider2Name, fakeConfig)

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

	// Get key materials from the fake provider1 and compare it to the ones we
	// pushed above.
	ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
	defer cancel()
	gotKM, err := prov1.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)
	}

	// Get key materials from the fake provider2 and compare it to the ones we
	// pushed above.
	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)
	}
}
// TestStoreWithMultipleProviders creates multiple providers of different types
// and make sure closing of one does not affect the other.
TestStoreWithMultipleProviders creates multiple providers of different types
and make sure closing of one does not affect the other.
// TestStoreWithMultipleProviders creates multiple providers of different types // and make sure closing of one does not affect the other .
func (s) TestStoreWithMultipleProviders(t *testing.T) {
	prov1, fp1 := makeProvider(t, fakeProvider1Name, fakeConfig)
	prov2, fp2 := makeProvider(t, fakeProvider2Name, fakeConfig)
	wantKM, err := loadKeyMaterials()
	if err != nil {
		t.Fatal(err)
	}
	fp1.kmCh <- wantKM
	fp2.kmCh <- wantKM
	ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
	defer cancel()
	gotKM, err := prov1.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)
	}
	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 ) TestStoreWithMultipleProviders ( t * testing . T ) { prov1 , fp1 := makeProvider ( t , fakeProvider1Name , fakeConfig ) prov2 , fp2 := makeProvider ( t , fakeProvider2Name , fakeConfig ) wantKM , err := loadKeyMaterials ( ) if err != nil { t . Fatal ( err ) } fp1 . kmCh <- wantKM fp2 . kmCh <- wantKM ctx , cancel := context . WithTimeout ( context . Background ( ) , defaultTestTimeout ) defer cancel ( ) gotKM , err := prov1 . KeyMaterial ( ctx ) if err != nil { t . Fatalf ( " " , err ) } if ! reflect . DeepEqual ( gotKM , wantKM ) { t . Fatalf ( " " , gotKM , wantKM ) } 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 ) } }
TestStoreWithMultipleProviders creates multiple providers of different types
and make sure closing of one does not affect the other.
TestStoreWithMultipleProviders creates multiple providers of different types and make sure closing of one does not affect the other .
// Push key materials into the fake providers. // Get key materials from the fake provider1 and compare it to the ones we // pushed above. // 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.