Skip to content

Commit

Permalink
rename golang sdk package (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
mirzakhany authored Sep 26, 2023
1 parent 774e01f commit 5b95428
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 21 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/tag_go_sdk.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Tag Golang SDK
on:
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+

jobs:
job:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: context.ref.replace('/v', '/clients/dbctlgo/v'),
sha: context.sha
});
2 changes: 1 addition & 1 deletion clients/golang/client.go → clients/dbctlgo/client.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package golang
package dbctlgo

import (
"bytes"
Expand Down
14 changes: 8 additions & 6 deletions clients/golang/client_test.go → clients/dbctlgo/client_test.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
package golang
package dbctlgo_test

import (
"database/sql"

"testing"
// golang postgres driver

"github.com/gomodule/redigo/redis"
_ "github.com/gomodule/redigo/redis"
"github.com/mirzakhany/clients/dbctlgo"

// golang postgres driver
_ "github.com/lib/pq"
)

func TestMustCreatePostgresDB(t *testing.T) {
uri := MustCreatePostgresDB(t, WithMigrations("./test_sql/schema"))
uri := dbctlgo.MustCreatePostgresDB(t, dbctlgo.WithMigrations("../test_sql/schema"))
if uri == "" {
t.Fatal("url is empty")
}
Expand Down Expand Up @@ -51,7 +53,7 @@ func TestMustCreatePostgresDB(t *testing.T) {
}

func TestPostgresDBWithFixtures(t *testing.T) {
uri := MustCreatePostgresDB(t, WithMigrations("./test_sql/schema"), WithFixtures("./test_sql/fixtures"))
uri := dbctlgo.MustCreatePostgresDB(t, dbctlgo.WithMigrations("../test_sql/schema"), dbctlgo.WithFixtures("../test_sql/fixtures"))
if uri == "" {
t.Fatal("url is empty")
}
Expand Down Expand Up @@ -94,7 +96,7 @@ func TestPostgresDBWithFixtures(t *testing.T) {
}

func TestRedis(t *testing.T) {
uri := MustCreateRedisDB(t)
uri := dbctlgo.MustCreateRedisDB(t)
if uri == "" {
t.Fatal("url is empty")
}
Expand Down
11 changes: 11 additions & 0 deletions clients/dbctlgo/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module github.com/mirzakhany/dbctl/clients/golang/dbctl

go 1.21.0

require (
github.com/gomodule/redigo v1.8.9
github.com/lib/pq v1.10.9
github.com/mirzakhany/clients/dbctlgo v0.0.0-unpublished
)

replace github.com/mirzakhany/clients/dbctlgo v0.0.0-unpublished => ./
File renamed without changes.
2 changes: 1 addition & 1 deletion clients/golang/options.go → clients/dbctlgo/options.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package golang
package dbctlgo

import (
"fmt"
Expand Down
8 changes: 0 additions & 8 deletions clients/golang/go.mod

This file was deleted.

File renamed without changes.
15 changes: 10 additions & 5 deletions docs/testing/golang.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,25 @@ dbclt testing -- pg

Use sdk in test:

Install the sdk:
```shell
go get github.com/mirzakhany/clients/dbctlgo
```

```golang
package foo

import (
"database/sql"

"testing"
dbctl "github.com/mirzakhany/dbctl/clients/golang"
"github.com/mirzakhany/clients/dbctlgo"
// golang postgres driver
_ "github.com/lib/pq"
)

func TestMustCreatePostgresDB(t *testing.T) {
uri := dbctl.MustCreatePostgresDB(t)
uri := dbctlgo.MustCreatePostgresDB(t)
if uri == "" {
t.Fatal("url is empty")
}
Expand Down Expand Up @@ -57,7 +62,7 @@ func TestMustCreatePostgresDB(t *testing.T) {
We can also apply migrations before starting the test.
```golang
func TestMustCreatePostgresDB(t *testing.T) {
uri := dbctl.MustCreatePostgresDB(t, dbctl.WithMigrations("./test_sql/schema"), dbctl.WithFixtures("./test_sql/fixtures"))
uri := dbctlgo.MustCreatePostgresDB(t, dbctlgo.WithMigrations("./test_sql/schema"), dbctlgo.WithFixtures("./test_sql/fixtures"))
if uri == "" {
t.Fatal("url is empty")
}
Expand Down Expand Up @@ -85,12 +90,12 @@ import (
"database/sql"

"testing"
dbctl "github.com/mirzakhany/dbctl/clients/golang"
"github.com/mirzakhany/clients/dbctlgo"
"github.com/gomodule/redigo/redis"
)

func TestRedis(t *testing.T) {
uri := dbctl.MustCreateRedisDB(t)
uri := dbctlgo.MustCreateRedisDB(t)
if uri == "" {
t.Fatal("url is empty")
}
Expand Down

0 comments on commit 5b95428

Please sign in to comment.