forked from pgvector/pgvector-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: move third party tests to subdirectory
- Loading branch information
Showing
13 changed files
with
373 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 => ./.. |
Oops, something went wrong.