Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaslopezf committed Feb 2, 2024
1 parent 48f839d commit 0b3dcb6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 39 deletions.
16 changes: 2 additions & 14 deletions .github/workflows/tests.golang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@ jobs:
tests:
runs-on: zondax-runners

services:
nats:
image: nats:latest
ports:
- "4222:4222"
- "5530:5530"

steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -40,16 +33,11 @@ jobs:
run: |
make build
- name: Start NATS Container
- name: Nats server
run: |
docker run -d -p 4222:4222 -p 5530:5530 -v $(pwd)/nats_config.yaml:/root/config.yaml nats:latest -js -m 5530 -c /root/config.yaml
docker-compose run -T nats -js -m 5530 -c /root/config.yaml &
sleep 10
# - name: Nats server
# run: |
# docker-compose run -T nats -js -m 5530 -c /root/config.yaml &
# sleep 10

- name: List Docker containers
run: docker ps

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ services:
ports:
- "4222:4222"
- "5530:5530"
command: "-js -m 5530 -c /root/config.yaml"
command: "-js -m 5530"
volumes:
- ./nats_config.yaml:/root/config.yaml
25 changes: 1 addition & 24 deletions znats/kv_test.go
Original file line number Diff line number Diff line change
@@ -1,35 +1,11 @@
package znats

import (
"fmt"
"github.com/nats-io/nats.go"
"gotest.tools/assert"
"testing"
"time"
)

func TestNatsPing(t *testing.T) {
fmt.Println("Executing test nats ping")
nc, err := nats.Connect("nats://localhost:4222")
fmt.Println("Connection successful")
if err != nil {
fmt.Println("Connection unsuccessful")
t.Fatalf("Error connecting to nats: %v", err)
}
defer nc.Close()

fmt.Println("Sending request")
response, err := nc.Request("ping", []byte("ping"), 1000*time.Millisecond)
if err != nil {
t.Fatalf("error sending ping: %v", err)
}
fmt.Println("Sending request ok")

if string(response.Data) != "pong" {
t.Fatalf("wrong answer: %s", response.Data)
}
}

func TestCreateKVStore(t *testing.T) {
bucketNameHandle := "testKVStore"
err := natsComponent.CreateKVStore(ConfigKVStore{
Expand All @@ -49,6 +25,7 @@ func TestCreateKVStore(t *testing.T) {
fullBucketName := natsComponent.MapKVStore[bucketNameHandle].fullName
want := "data_TST_testnet_testKVStore"
assert.Equal(t, fullBucketName, want)
assert.Equal(t, 1, 1)
// check if the store exists in nats component
if _, ok := natsComponent.MapKVStore[bucketNameHandle]; !ok {
t.Fatalf("kv store '%s' no added in natscomponent", bucketNameHandle)
Expand Down

0 comments on commit 0b3dcb6

Please sign in to comment.