69
internal/storage/storage_test.go
Normal file
69
internal/storage/storage_test.go
Normal file
@@ -0,0 +1,69 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"git.unistack.org/unistack-org/pkgdash/internal/storage/sqlite"
|
||||
pb "git.unistack.org/unistack-org/pkgdash/proto"
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
st := sqlite.NewStorage()
|
||||
store := st(conn, fs)
|
||||
|
||||
s, ok := store.(Storage)
|
||||
if !ok {
|
||||
t.Fatal("dont implements interface Storage")
|
||||
}
|
||||
|
||||
req := &pb.GetModuleReq{
|
||||
Id: []uint64{1, 2, 3},
|
||||
}
|
||||
|
||||
module, err := s.GetModule(context.Background(), req)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
fmt.Println(module)
|
||||
}
|
||||
|
||||
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())
|
||||
}
|
Reference in New Issue
Block a user