Skip to content

Commit 20fd6d1

Browse files
chore: update deps and workflow actions (#88)
**Description** * Updated go.mod to resolve vulnerabilities * Updated workflow action to include new API tests **Checklist** - [x] Code compiles correctly and linting passes locally
1 parent df9ca18 commit 20fd6d1

File tree

6 files changed

+17
-14
lines changed

6 files changed

+17
-14
lines changed

.github/workflows/ci-go-unit-tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ jobs:
3838
cache-dependency-path: go.sum
3939

4040
- name: Run Unit Tests
41-
run: go test -race -v ./unit_test/...
41+
run: go test -race -v . ./unit_test/...

engine.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,18 @@ var (
3535
// This ensures that we only have one instance of modusDB in this process.
3636
singleton atomic.Bool
3737

38-
ErrSingletonOnly = errors.New("only one modusDB engine is supported")
38+
ErrSingletonOnly = errors.New("only one instance of modusDB can exist in a process")
3939
ErrEmptyDataDir = errors.New("data directory is required")
4040
ErrClosedEngine = errors.New("modusDB engine is closed")
4141
ErrNonExistentDB = errors.New("namespace does not exist")
4242
)
4343

44+
// ResetSingleton resets the singleton state for testing purposes.
45+
// This should ONLY be called during testing, typically in cleanup functions.
46+
func ResetSingleton() {
47+
singleton.Store(false)
48+
}
49+
4450
// Engine is an instance of modusDB.
4551
// For now, we only support one instance of modusDB per process.
4652
type Engine struct {

go.mod

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
module github.com/hypermodeinc/modusgraph
22

3-
go 1.24.1
4-
5-
toolchain go1.24.2
3+
go 1.24.2
64

75
require (
86
github.com/cavaliergopher/grab/v3 v3.0.1
@@ -151,5 +149,3 @@ require (
151149
gopkg.in/yaml.v2 v2.4.0 // indirect
152150
gopkg.in/yaml.v3 v3.0.1 // indirect
153151
)
154-
155-
replace github.com/dolan-in/dgman/v2 => github.com/matthewmcneely/dgman/v2 v2.0.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj
149149
github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc=
150150
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
151151
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
152+
github.com/dolan-in/dgman/v2 v2.0.0 h1:kMhUo3dYr4SCWJe87cNbBctD5f2fC+pX/cLz52pVYAE=
153+
github.com/dolan-in/dgman/v2 v2.0.0/go.mod h1:JI2D8vtkMBp9Ec8/wBPuJPPT89C+HQnQYb0biuXo4do=
152154
github.com/dolan-in/reflectwalk v1.0.2-0.20210101124621-dc2073a29d71 h1:v3bErDrPApxsyBlz8/8nFTCb7Ai0wecA8TokfEHIQ80=
153155
github.com/dolan-in/reflectwalk v1.0.2-0.20210101124621-dc2073a29d71/go.mod h1:Y9TyDkSL5jQ18ZnDaSxOdCUhbb5SCeamqYFQ7LYxxFs=
154156
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
@@ -388,8 +390,6 @@ github.com/ledongthuc/pdf v0.0.0-20220302134840-0c2507a12d80/go.mod h1:imJHygn/1
388390
github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4=
389391
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
390392
github.com/matryer/moq v0.0.0-20200106131100-75d0ddfc0007/go.mod h1:9ELz6aaclSIGnZBoaSLZ3NAl1VTufbOrXBPvtcy6WiQ=
391-
github.com/matthewmcneely/dgman/v2 v2.0.1 h1:rdqClEb0tFd7PhjFfWC9771Z7RiqtoX7GU6IqJbeAfg=
392-
github.com/matthewmcneely/dgman/v2 v2.0.1/go.mod h1:GOuKyhoakfLVKw2xJTazd0rfEeeMF3UB2oejL0xsr30=
393393
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
394394
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
395395
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=

unit_test/conn_test.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,14 @@ package unit_test
1818

1919
import (
2020
"context"
21-
"fmt"
2221
"testing"
2322

2423
"github.com/dgraph-io/dgo/v240/protos/api"
2524
"github.com/hypermodeinc/modusgraph"
2625
"github.com/stretchr/testify/require"
2726
)
2827

29-
// TestDgraphWithBufconn tests Dgraph operations using bufconn
30-
func TestDgraphWithBufconn(t *testing.T) {
28+
func TestRDF(t *testing.T) {
3129
// Create a new engine - this initializes all the necessary components
3230
engine, err := modusgraph.NewEngine(modusgraph.NewDefaultConfig(t.TempDir()))
3331
require.NoError(t, err)
@@ -43,7 +41,7 @@ func TestDgraphWithBufconn(t *testing.T) {
4341
txn := client.NewReadOnlyTxn()
4442
resp, err := txn.Query(ctx, "schema {}")
4543
require.NoError(t, err)
46-
fmt.Println("resp", resp)
44+
require.NotEmpty(t, resp.Json)
4745
_ = txn.Discard(ctx)
4846

4947
txn = client.NewTxn()
@@ -64,7 +62,7 @@ func TestDgraphWithBufconn(t *testing.T) {
6462
// Query to verify the mutation worked
6563
resp, err = txn.Query(ctx, `{ q(func: has(n)) { n } }`)
6664
require.NoError(t, err)
67-
fmt.Println("query after mutation:", resp)
65+
require.NotEmpty(t, resp.Json)
6866
_ = txn.Discard(ctx)
6967

7068
err = client.Alter(context.Background(), &api.Operation{DropAll: true})

util_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ func CreateTestClient(t *testing.T, uri string) (mg.Client, func()) {
3939
t.Error(err)
4040
}
4141
client.Close()
42+
43+
// Reset the singleton state so the next test can create a new engine
44+
mg.ResetSingleton()
4245
}
4346

4447
return client, cleanup

0 commit comments

Comments
 (0)