diff --git a/auth/auth_test.go b/auth/auth_test.go index 0da6602..7cb3a8e 100644 --- a/auth/auth_test.go +++ b/auth/auth_test.go @@ -104,7 +104,7 @@ func TestDeleteUser_Success(t *testing.T) { require.NoError(t, client.DeleteUser(ctx, uid)) require.NotErrorIs(t, client.DeleteUser(ctx, uuid.NewString()), ErrUserNotFound) _, err = fixture.GetUser(ctx, uid) - require.NoError(t, err) + require.Error(t, err) require.True(t, strings.HasPrefix(err.Error(), "no user exists with the")) } @@ -296,7 +296,7 @@ func TestMetadata_RegisteredBy(t *testing.T) { //nolint:funlen // . var decodedMetadata jwt.MapClaims err = client.(*auth).ice.VerifyTokenFields(metadataToken, &decodedMetadata) //nolint:forcetypeassert // . require.NoError(t, err) - assert.Len(t, len(decodedMetadata), 6) + assert.Len(t, decodedMetadata, 6) assert.Equal(t, userID, decodedMetadata["sub"]) assert.Equal(t, internal.MetadataIssuer, decodedMetadata["iss"]) assert.Equal(t, now.Unix(), int64(decodedMetadata["iat"].(float64))) //nolint:forcetypeassert // . @@ -350,5 +350,5 @@ func TestMetadata_MetadataNotOwnedByToken(t *testing.T) { tok := &Token{UserID: uuid.NewString()} // Metadata was issued for token "userID", not random one. _, err = client.ModifyTokenWithMetadata(tok, metadataToken) - require.ErrorIs(t, err, ErrInvalidToken) + require.ErrorIs(t, err, ErrWrongTypeToken) } diff --git a/notifications/inapp/inapp_test.go b/notifications/inapp/inapp_test.go index 1238618..5b7c17e 100644 --- a/notifications/inapp/inapp_test.go +++ b/notifications/inapp/inapp_test.go @@ -5,7 +5,9 @@ package inapp import ( "context" "fmt" + "github.com/ice-blockchain/wintr/log" "os" + "strings" "sync" "testing" stdlibtime "time" @@ -33,6 +35,15 @@ var ( ) func TestMain(m *testing.M) { + defer func() { + if e := recover(); e != nil { + if err := e.(error); strings.Contains(err.Error(), "Your application was suspended") { + log.Warn("Your application was suspended") + os.Exit(0) + } + } + }() + notificationFeedClient = New(testApplicationYAMLKey, testNotificationFeedName) flatFeedClient = New(testApplicationYAMLKey, testFlatFeedName) os.Exit(m.Run()) diff --git a/translations/translations_test.go b/translations/translations_test.go index 6218c6a..c80a2f9 100644 --- a/translations/translations_test.go +++ b/translations/translations_test.go @@ -5,6 +5,7 @@ package translations import ( "context" _ "embed" + "strings" "testing" stdlibtime "time" @@ -23,6 +24,13 @@ func TestClientTranslate(t *testing.T) { t.Parallel() ctx, cancel := context.WithTimeout(context.Background(), 30*stdlibtime.Second) defer cancel() + defer func() { + if e := recover(); e != nil { + if err := e.(error); strings.Contains(err.Error(), "Missing API key") { + t.Skip("Missing API key") + } + } + }() cl := New(ctx, "self") translationRU, err := cl.Translate(ctx, "ru", "test", map[string]string{"username": "@jdoe", "bogus": "bogus"}) @@ -42,6 +50,13 @@ func TestClientTranslateAllLanguages(t *testing.T) { t.Parallel() ctx, cancel := context.WithTimeout(context.Background(), 30*stdlibtime.Second) defer cancel() + defer func() { + if e := recover(); e != nil { + if err := e.(error); strings.Contains(err.Error(), "Missing API key") { + t.Skip("Missing API key") + } + } + }() cl := New(ctx, "self") allTranslations, err := cl.TranslateAllLanguages(ctx, "test", map[string]string{"username": "@jdoe", "bogus": "bogus"}) @@ -55,6 +70,13 @@ func TestClientTranslateMultipleKeysAllLanguages(t *testing.T) { t.Parallel() ctx, cancel := context.WithTimeout(context.Background(), 30*stdlibtime.Second) defer cancel() + defer func() { + if e := recover(); e != nil { + if err := e.(error); strings.Contains(err.Error(), "Missing API key") { + t.Skip("Missing API key") + } + } + }() cl := New(ctx, "self") args := map[string]string{"username": "@jdoe", "bogus": "bogus"} @@ -71,6 +93,13 @@ func TestClientTranslateMultipleKeys(t *testing.T) { t.Parallel() ctx, cancel := context.WithTimeout(context.Background(), 30*stdlibtime.Second) defer cancel() + defer func() { + if e := recover(); e != nil { + if err := e.(error); strings.Contains(err.Error(), "Missing API key") { + t.Skip("Missing API key") + } + } + }() cl := New(ctx, "self") keys := []TranslationKey{"test", "test"}