package sqlite import ( "fmt" "os" "strings" "testing" "time" "forge.cadoles.com/arcad/edge/pkg/storage/share" "forge.cadoles.com/arcad/edge/pkg/storage/share/testsuite" "github.com/pkg/errors" "gitlab.com/wpetit/goweb/logger" ) func TestRepository(t *testing.T) { logger.SetLevel(logger.LevelDebug) testsuite.TestStore(t, newTestStore) } func newTestStore(testName string) (share.Store, error) { filename := strings.ToLower(strings.ReplaceAll(testName, " ", "_")) file := fmt.Sprintf("./testdata/%s.sqlite", filename) if err := os.Remove(file); err != nil && !errors.Is(err, os.ErrNotExist) { return nil, errors.WithStack(err) } dsn := fmt.Sprintf("%s?_pragma=foreign_keys(1)&_pragma=busy_timeout=%d", file, (60 * time.Second).Milliseconds()) store := NewShareStore(dsn) return store, nil }