github.com/cozy/cozy-stack@v0.0.0-20240603063001-31110fa4cae1/worker/push/push_test.go (about) 1 package push 2 3 import ( 4 "testing" 5 6 "github.com/cozy/cozy-stack/model/account" 7 "github.com/cozy/cozy-stack/pkg/config/config" 8 "github.com/cozy/cozy-stack/pkg/couchdb" 9 "github.com/cozy/cozy-stack/pkg/prefixer" 10 "github.com/cozy/cozy-stack/tests/testutils" 11 "github.com/stretchr/testify/assert" 12 "github.com/stretchr/testify/require" 13 ) 14 15 func TestPush(t *testing.T) { 16 if testing.Short() { 17 t.Skip("a couchdb is required for this test: test skipped due to the use of --short flag") 18 } 19 20 config.UseTestFile(t) 21 testutils.NeedCouchdb(t) 22 23 t.Run("DeprecateLegacyFCM", func(t *testing.T) { 24 testutils.TODO(t, "2024-07-01", "Remove the deprecated calls to the legacy FCM API") 25 }) 26 27 t.Run("get firebase client", func(t *testing.T) { 28 contextName := "foo" 29 slug := "bar" 30 31 // Ensure that the global legacyFCMClient is nil for this test, and restore its 32 // old value after the test 33 oldFcmClient := legacyFCMClient 34 legacyFCMClient = nil 35 defer func() { 36 legacyFCMClient = oldFcmClient 37 }() 38 39 // Create an account type for the test 40 typ := account.AccountType{ 41 DocID: contextName + "/" + slug, 42 Slug: slug, 43 AndroidAPIKey: "th3_f1r3b4s3_k3y", 44 } 45 err := couchdb.CreateNamedDoc(prefixer.SecretsPrefixer, &typ) 46 require.NoError(t, err) 47 48 defer func() { 49 _ = couchdb.DeleteDoc(prefixer.SecretsPrefixer, &typ) 50 }() 51 52 client := getLegacyFirebaseClient(slug, contextName) 53 assert.NotNil(t, client) 54 }) 55 }