2023-08-11 20:12:15 +03:00
|
|
|
package storage
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"database/sql"
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
2023-08-16 13:17:42 +03:00
|
|
|
|
2024-12-07 02:35:30 +03:00
|
|
|
"go.unistack.org/pkgdash/internal/storage/sqlite"
|
|
|
|
pb "go.unistack.org/pkgdash/proto"
|
2023-08-11 20:12:15 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestGetModule(t *testing.T) {
|
|
|
|
conn, err := sql.Open("sqlite3", "/Users/devstigneev_local/GolandProjects/unistack/pkgdash/identifier.sqlite")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
defer conn.Close()
|
|
|
|
if err = conn.Ping(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2023-08-13 00:09:57 +03:00
|
|
|
st := sqlite.NewStorage()
|
|
|
|
store := st(conn, fs)
|
2023-08-11 20:12:15 +03:00
|
|
|
|
2023-08-13 00:09:57 +03:00
|
|
|
s, ok := store.(Storage)
|
2023-08-11 20:12:15 +03:00
|
|
|
if !ok {
|
2023-08-13 00:09:57 +03:00
|
|
|
t.Fatal("dont implements interface Storage")
|
2023-08-11 20:12:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
req := &pb.GetModuleReq{
|
2023-08-13 00:09:57 +03:00
|
|
|
Id: []uint64{1, 2, 3},
|
2023-08-11 20:12:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
module, err := s.GetModule(context.Background(), req)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Println(module)
|
|
|
|
}
|
2023-08-14 14:27:29 +03:00
|
|
|
|
|
|
|
func TestGetComment(t *testing.T) {
|
|
|
|
conn, err := sql.Open("sqlite3", "/Users/devstigneev_local/GolandProjects/unistack/pkgdash/identifier.sqlite")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
defer conn.Close()
|
|
|
|
if err = conn.Ping(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
st := sqlite.NewStorage()
|
|
|
|
store := st(conn, fs)
|
|
|
|
|
|
|
|
s, ok := store.(Storage)
|
|
|
|
if !ok {
|
|
|
|
t.Fatal("dont implements interface Storage")
|
|
|
|
}
|
|
|
|
|
|
|
|
req := &pb.GetCommentsReq{
|
|
|
|
Id: []uint64{1, 2, 3, 15},
|
|
|
|
}
|
|
|
|
comments, err := s.GetComment(context.Background(), req)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
fmt.Println(comments.Decode())
|
|
|
|
}
|