Skip to content

Commit

Permalink
test: Add tests for the SetAsset function
Browse files Browse the repository at this point in the history
  • Loading branch information
Dobefu committed Jan 15, 2025
1 parent 4f68c9c commit 1fb2346
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions cmd/database/assets/set-asset_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package assets

import (
"os"
"testing"

"github.com/Dobefu/csb/cmd/cs_sdk/structs"
"github.com/Dobefu/csb/cmd/database"
"github.com/Dobefu/csb/cmd/init_env"
"github.com/Dobefu/csb/cmd/migrate_db"
"github.com/stretchr/testify/assert"
)

func TestSetAsset(t *testing.T) {
init_env.Main("../../../.env.test")
var err error

oldDb := os.Getenv("DB_CONN")
os.Setenv("DB_CONN", "file:/")
err = database.Connect()
assert.Equal(t, nil, err)

err = SetAsset(structs.Asset{})
assert.NotEqual(t, nil, err)

os.Setenv("DB_CONN", oldDb)
err = database.Connect()
assert.Equal(t, nil, err)

err = migrate_db.Main(true)
assert.Equal(t, nil, err)

err = SetAsset(structs.Asset{})
assert.Equal(t, nil, err)
}

0 comments on commit 1fb2346

Please sign in to comment.