Skip to content

Commit

Permalink
merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
hgiasac committed Jul 14, 2024
2 parents b1f94ac + 1d68c4a commit d55cbf1
Show file tree
Hide file tree
Showing 10 changed files with 406 additions and 217 deletions.
16 changes: 3 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,6 @@ jobs:
- uses: actions/setup-go@v5
with:
go-version: "1.20"
- uses: actions/cache@v4
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install dependencies
run: |
go get -t -v ./...
Expand All @@ -52,8 +44,6 @@ jobs:
version: latest
only-new-issues: true
skip-cache: true
skip-pkg-cache: true
skip-build-cache: true
args: --timeout=120s
- name: Run Go unit tests for example/subscription
run: |
Expand All @@ -63,13 +53,13 @@ jobs:
- name: Run Go unit tests
run: go test -v -race -timeout 3m -coverprofile=coverage.out ./...
- name: Go coverage format
if: ${{ github.event_name == 'pull_request' }}
if: ${{ github.event_name == 'pull_request' && github.repository == 'hasura/go-graphql-client' }}
run: |
go get github.com/boumenot/gocover-cobertura
go install github.com/boumenot/gocover-cobertura
gocover-cobertura < coverage.out > coverage.xml
- name: Code Coverage Summary Report
if: ${{ github.event_name == 'pull_request' }}
if: ${{ github.event_name == 'pull_request' && github.repository == 'hasura/go-graphql-client' }}
uses: irongut/CodeCoverageSummary@v1.3.0
with:
filename: coverage.xml
Expand All @@ -83,7 +73,7 @@ jobs:
thresholds: "60 80"
- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v2
if: ${{ github.event_name == 'pull_request' }}
if: ${{ github.event_name == 'pull_request' && github.repository == 'hasura/go-graphql-client' }}
with:
path: code-coverage-results.md
- name: Dump docker logs on failure
Expand Down
222 changes: 132 additions & 90 deletions README.md

Large diffs are not rendered by default.

38 changes: 19 additions & 19 deletions example/graphql-ws-bc/server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions example/graphql-ws-bc/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
},
"license": "MIT",
"dependencies": {
"graphql": "^16.8.1",
"graphql-ws": "^5.14.3",
"graphql": "^16.9.0",
"graphql-ws": "^5.16.0",
"subscriptions-transport-ws": "^0.11.0",
"ws": "^8.16.0"
"ws": "^8.17.1"
},
"devDependencies": {
"@types/ws": "^8.5.10",
"ts-node": "^10.9.2",
"typescript": "^5.3.3"
"typescript": "^5.5.2"
}
}
19 changes: 9 additions & 10 deletions example/subscription/subscription_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"log"
"net/http"
"sync"
"sync/atomic"
"testing"
"time"

Expand Down Expand Up @@ -370,8 +371,7 @@ func testSubscription_LifeCycleEvents(t *testing.T, syncMode bool) {

var lock sync.Mutex
subscriptionResults := []gql.Subscription{}
wasConnected := false
wasDisconnected := false
var wasConnected, wasDisconnected int32
addResult := func(s gql.Subscription) int {
lock.Lock()
defer lock.Unlock()
Expand Down Expand Up @@ -436,20 +436,16 @@ func testSubscription_LifeCycleEvents(t *testing.T, syncMode bool) {
WithTimeout(3 * time.Second).
WithSyncMode(syncMode).
OnConnected(func() {
lock.Lock()
defer lock.Unlock()
log.Println("connected")
wasConnected = true
atomic.StoreInt32(&wasConnected, 1)
}).
OnError(func(sc *gql.SubscriptionClient, err error) error {
t.Fatalf("got error: %v, want: nil", err)
return err
}).
OnDisconnected(func() {
lock.Lock()
defer lock.Unlock()
log.Println("disconnected")
wasDisconnected = true
atomic.StoreInt32(&wasDisconnected, 1)
}).
OnSubscriptionComplete(func(s gql.Subscription) {
log.Println("OnSubscriptionComplete: ", s)
Expand Down Expand Up @@ -542,10 +538,13 @@ func testSubscription_LifeCycleEvents(t *testing.T, syncMode bool) {
}
}

if !wasConnected {
// workaround for race condition
time.Sleep(time.Second)

if atomic.LoadInt32(&wasConnected) != 1 {
t.Fatalf("expected OnConnected event, got none")
}
if !wasDisconnected {
if atomic.LoadInt32(&wasDisconnected) != 1 {
t.Fatalf("expected OnDisconnected event, got none")
}
}
Expand Down
Loading

0 comments on commit d55cbf1

Please sign in to comment.