Skip to content

Commit

Permalink
tests: move third party tests to subdirectory
Browse files Browse the repository at this point in the history
  • Loading branch information
tmc committed Nov 11, 2023
1 parent 0532dce commit 3bffe2a
Show file tree
Hide file tree
Showing 13 changed files with 373 additions and 40 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ jobs:
fail-fast: false
matrix:
go: ["1.21", "1.20"]
pgvector: ["v0.5.1", "master"]
]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
Expand All @@ -19,9 +21,12 @@ jobs:
dev-files: true
- run: |
cd /tmp
git clone --branch v0.5.0 https://github.com/pgvector/pgvector.git
git clone --branch ${{ matrix.go }} https://github.com/pgvector/pgvector.git
cd pgvector
make
sudo make install
- run: go test -v
- run: go generate ./ent && go mod tidy
working-directory: third-party-tests
- run: go test -v
working-directory: third-party-tests
38 changes: 0 additions & 38 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,41 +1,3 @@
module github.com/pgvector/pgvector-go

go 1.20

require (
entgo.io/ent v0.12.4
github.com/go-pg/pg/v10 v10.11.0
github.com/jackc/pgx/v5 v5.3.1
github.com/lib/pq v1.10.9
github.com/uptrace/bun v1.1.12
github.com/uptrace/bun/dialect/pgdialect v1.1.12
github.com/uptrace/bun/driver/pgdriver v1.1.12
)

require (
ariga.io/atlas v0.14.1-0.20230918065911-83ad451a4935 // indirect
github.com/agext/levenshtein v1.2.1 // indirect
github.com/ankane/disco-go v0.1.0 // indirect
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
github.com/go-openapi/inflect v0.19.0 // indirect
github.com/go-pg/zerochecker v0.2.0 // indirect
github.com/google/go-cmp v0.5.6 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/hashicorp/hcl/v2 v2.13.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 // indirect
github.com/rogpeppe/go-internal v1.9.0 // indirect
github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc // indirect
github.com/vmihailenco/bufpool v0.1.11 // indirect
github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect
github.com/vmihailenco/tagparser v0.1.2 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/zclconf/go-cty v1.8.0 // indirect
golang.org/x/crypto v0.6.0 // indirect
golang.org/x/mod v0.10.0 // indirect
golang.org/x/sys v0.7.0 // indirect
golang.org/x/text v0.8.0 // indirect
mellium.im/sasl v0.3.1 // indirect
)
144 changes: 144 additions & 0 deletions pgvector_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
package pgvector

import (
"database/sql/driver"
"reflect"
"testing"
)

func TestNewVector(t *testing.T) {
v := NewVector([]float32{1, 2, 3})
v.Slice()
}

func TestVector_Slice(t *testing.T) {
type fields struct {
vec []float32
}
tests := []struct {
name string
fields fields
want []float32
}{
{"test", fields{[]float32{1, 2, 3}}, []float32{1, 2, 3}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
v := Vector{
vec: tt.fields.vec,
}
if got := v.Slice(); !reflect.DeepEqual(got, tt.want) {
t.Errorf("Vector.Slice() = %v, want %v", got, tt.want)
}
})
}
}

func TestVector_String(t *testing.T) {
type fields struct {
vec []float32
}
tests := []struct {
name string
fields fields
want string
}{
{"test", fields{[]float32{1, 2, 3}}, "[1,2,3]"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
v := Vector{
vec: tt.fields.vec,
}
if got := v.String(); got != tt.want {
t.Errorf("Vector.String() = %v, want %v", got, tt.want)
}
})
}
}

func TestVector_Parse(t *testing.T) {
type fields struct {
vec []float32
}
type args struct {
s string
}
tests := []struct {
name string
fields fields
args args
wantErr bool
}{
{"ok", fields{[]float32{1, 2, 3}}, args{"[1,2,3]"}, false},
{"err", fields{[]float32{1, 2, 3}}, args{"[1,2,3"}, true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
v := &Vector{
vec: tt.fields.vec,
}
if err := v.Parse(tt.args.s); (err != nil) != tt.wantErr {
t.Errorf("Vector.Parse() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}

func TestVector_Scan(t *testing.T) {
type fields struct {
vec []float32
}
type args struct {
src any
}
tests := []struct {
name string
fields fields
args args
wantErr bool
}{
{"string", fields{[]float32{1, 2, 3}}, args{"[1,2,3]"}, false},
{"[]byte", fields{[]float32{1, 2, 3}}, args{[]byte("[1,2,3]")}, false},
{"unsupported", fields{[]float32{1, 2, 3}}, args{1}, true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
v := &Vector{
vec: tt.fields.vec,
}
if err := v.Scan(tt.args.src); (err != nil) != tt.wantErr {
t.Errorf("Vector.Scan() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}

func TestVector_Value(t *testing.T) {
type fields struct {
vec []float32
}
tests := []struct {
name string
fields fields
want driver.Value
wantErr bool
}{
{"ok", fields{[]float32{1, 2, 3}}, "[1,2,3]", false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
v := Vector{
vec: tt.fields.vec,
}
got, err := v.Value()
if (err != nil) != tt.wantErr {
t.Errorf("Vector.Value() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("Vector.Value() = %v, want %v", got, tt.want)
}
})
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion ent_test.go → third-party-tests/ent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"entgo.io/ent/dialect/sql"
_ "github.com/lib/pq"
"github.com/pgvector/pgvector-go"
"github.com/pgvector/pgvector-go/ent"
"github.com/pgvector/pgvector-go/third-party-tests/ent"
)

func TestEnt(t *testing.T) {
Expand Down
37 changes: 37 additions & 0 deletions third-party-tests/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module github.com/pgvector/pgvector-go/third-party-tests

go 1.20

require (
entgo.io/ent v0.12.4
github.com/ankane/disco-go v0.1.0
github.com/go-pg/pg/v10 v10.11.0
github.com/jackc/pgx/v5 v5.3.1
github.com/lib/pq v1.10.9
github.com/pgvector/pgvector-go v0.0.0-00010101000000-000000000000
github.com/uptrace/bun v1.1.12
github.com/uptrace/bun/dialect/pgdialect v1.1.12
github.com/uptrace/bun/driver/pgdriver v1.1.12
)

require (
github.com/go-pg/zerochecker v0.2.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/rogpeppe/go-internal v1.9.0 // indirect
github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc // indirect
github.com/vmihailenco/bufpool v0.1.11 // indirect
github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect
github.com/vmihailenco/tagparser v0.1.2 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
golang.org/x/crypto v0.6.0 // indirect
golang.org/x/sys v0.7.0 // indirect
golang.org/x/text v0.8.0 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
mellium.im/sasl v0.3.1 // indirect
)

replace github.com/pgvector/pgvector-go => ./..
Loading

0 comments on commit 3bffe2a

Please sign in to comment.