@@ -4,12 +4,15 @@ import (
44 "errors"
55 "testing"
66
7+ "github.com/zalando/go-keyring"
8+
79 "github.com/flowexec/vault"
810)
911
1012const testKeyringService = "flowexec-vault-test"
1113
1214func TestKeyringVault_New (t * testing.T ) {
15+ keyring .MockInit ()
1316 vlt , cfg , err := vault .New ("test-keyring-vault" ,
1417 vault .WithProvider (vault .ProviderTypeKeyring ),
1518 vault .WithKeyringService (testKeyringService ),
@@ -37,6 +40,7 @@ func TestKeyringVault_New(t *testing.T) {
3740}
3841
3942func TestKeyringVault_SecretOperations (t * testing.T ) {
43+ keyring .MockInit ()
4044 vlt , _ , err := vault .New ("test-keyring-vault" ,
4145 vault .WithProvider (vault .ProviderTypeKeyring ),
4246 vault .WithKeyringService (testKeyringService ),
@@ -45,7 +49,6 @@ func TestKeyringVault_SecretOperations(t *testing.T) {
4549 t .Fatalf ("Failed to create keyring vault: %v" , err )
4650 }
4751 defer func () {
48- // Clean up any remaining secrets before closing
4952 secrets , _ := vlt .ListSecrets ()
5053 for _ , key := range secrets {
5154 _ = vlt .DeleteSecret (key )
@@ -123,6 +126,7 @@ func TestKeyringVault_SecretOperations(t *testing.T) {
123126}
124127
125128func TestKeyringVault_MultipleSecrets (t * testing.T ) {
129+ keyring .MockInit ()
126130 vlt , _ , err := vault .New ("test-keyring-vault-multiple" ,
127131 vault .WithProvider (vault .ProviderTypeKeyring ),
128132 vault .WithKeyringService (testKeyringService ),
@@ -205,6 +209,7 @@ func TestKeyringVault_MultipleSecrets(t *testing.T) {
205209}
206210
207211func TestKeyringVault_Persistence (t * testing.T ) {
212+ keyring .MockInit ()
208213 testKey := "persistent-keyring-key"
209214 testValue := "persistent-keyring-value"
210215
@@ -258,6 +263,7 @@ func TestKeyringVault_Persistence(t *testing.T) {
258263}
259264
260265func TestKeyringVault_Metadata (t * testing.T ) {
266+ keyring .MockInit ()
261267 vlt , _ , err := vault .New ("test-keyring-metadata" ,
262268 vault .WithProvider (vault .ProviderTypeKeyring ),
263269 vault .WithKeyringService (testKeyringService ),
@@ -293,6 +299,7 @@ func TestKeyringVault_Metadata(t *testing.T) {
293299}
294300
295301func TestKeyringVault_InvalidKeyValidation (t * testing.T ) {
302+ keyring .MockInit ()
296303 vlt , _ , err := vault .New ("test-keyring-validation" ,
297304 vault .WithProvider (vault .ProviderTypeKeyring ),
298305 vault .WithKeyringService (testKeyringService ),
@@ -325,6 +332,7 @@ func TestKeyringVault_InvalidKeyValidation(t *testing.T) {
325332}
326333
327334func TestKeyringVault_SortedOutput (t * testing.T ) {
335+ keyring .MockInit ()
328336 vlt , _ , err := vault .New ("test-keyring-sorted" ,
329337 vault .WithProvider (vault .ProviderTypeKeyring ),
330338 vault .WithKeyringService (testKeyringService ),
0 commit comments