package client_git import ( "context" "database/sql" "embed" "fmt" "testing" "git.unistack.org/unistack-org/pkgdash/internal/storage" // "git.unistack.org/unistack-org/pkgdash/internal/storage/postgres" "git.unistack.org/unistack-org/pkgdash/internal/storage/sqlite" pb "git.unistack.org/unistack-org/pkgdash/proto" ) func TestClientPG(t *testing.T) { dsn := fmt.Sprintf("file:///database.db") conn, err := sql.Open("sqlite", dsn) if err != nil { t.Fatal(err) } defer conn.Close() if err = conn.Ping(); err != nil { t.Fatal(err) } fucntion := sqlite.NewStorage() st := fucntion(conn, embed.FS{}) s, ok := st.(storage.Storage) if !ok { t.Fatal("typecast error") } ctx, cancel := context.WithCancel(context.Background()) _ = cancel cli := NewClient(1) ch := cli.Run(ctx, s) data := &pb.AddPackageReq{ Name: "test", Url: "https://github.com/dantedenis/service_history.git", } ch <- data <-cli.Done() } func TestClientLite(t *testing.T) { conn, err := sql.Open("sqlite3", "../../identifier.sqlite") if err != nil { t.Fatal(err) } defer conn.Close() if err = conn.Ping(); err != nil { t.Fatal(err) } function := sqlite.NewStorage() st := function(conn, embed.FS{}) s, ok := st.(storage.Storage) if !ok { t.Fatal("typecast error") } ctx, cancel := context.WithCancel(context.Background()) _ = cancel cli := NewClient(1) ch := cli.Run(ctx, s) data := &pb.AddPackageReq{ Name: "test", Url: "https://github.com/dantedenis/service_history.git", } ch <- data <-cli.Done() }