Skip to content

Commit

Permalink
Merge pull request #10 from nacos-group/master
Browse files Browse the repository at this point in the history
sync
  • Loading branch information
binbin0325 authored Oct 3, 2020
2 parents 96f93fb + 170bb4e commit 26e692c
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 38 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: CI

on:
push:
branches: "master"
pull_request:
branches: "*"

jobs:

build:
name: ubuntu-latest ${{ matrix.config.go_version }}
runs-on: ubuntu-latest
strategy:
matrix:
config:
- go_version: 1.13
- go_version: 1.14
steps:

- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.config.go_version }}
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Install goimports
run: go get golang.org/x/tools/cmd/goimports

- name: Test
run: |
diff -u <(echo -n) <(gofmt -d -s .)
diff -u <(echo -n) <(goimports -d .)
go test -v ./... -coverprofile=coverage.txt -covermode=atomic
- name: Coverage
run: bash <(curl -s https://codecov.io/bash)


20 changes: 0 additions & 20 deletions .travis.yml

This file was deleted.

31 changes: 14 additions & 17 deletions clients/config_client/config_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,15 +445,15 @@ func TestListen(t *testing.T) {
// ListenConfig no change
t.Run("TestListenConfigNoChange", func(t *testing.T) {
client := cretateConfigClientTest()
key := util.GetConfigCacheKey(localConfigTest.DataId, localConfigTest.Group, clientConfigTest.NamespaceId)
key := util.GetConfigCacheKey("ConfigNoChange", localConfigTest.Group, clientConfigTest.NamespaceId)
cache.WriteConfigToFile(key, client.configCacheDir, localConfigTest.Content)
var err error
var success bool
var content string

go func() {
err = client.ListenConfig(vo.ConfigParam{
DataId: localConfigTest.DataId,
DataId: "ConfigNoChange",
Group: localConfigTest.Group,
OnChange: func(namespace, group, dataId, data string) {
content = "data"
Expand All @@ -465,7 +465,7 @@ func TestListen(t *testing.T) {
time.Sleep(2 * time.Second)

success, err = client.PublishConfig(vo.ConfigParam{
DataId: localConfigTest.DataId,
DataId: "ConfigNoChange",
Group: localConfigTest.Group,
Content: localConfigTest.Content})

Expand All @@ -477,7 +477,7 @@ func TestListen(t *testing.T) {
t.Run("TestListenConfigWithMultipleClients", func(t *testing.T) {
ch := make(chan string)
listenConfigParam := vo.ConfigParam{
DataId: localConfigTest.DataId,
DataId: "MultipleClients",
Group: localConfigTest.Group,
OnChange: func(namespace, group, dataId, data string) {
fmt.Println("group:" + group + ", dataId:" + dataId + ", data:" + data)
Expand All @@ -493,7 +493,7 @@ func TestListen(t *testing.T) {
client1.ListenConfig(listenConfigParam)

success, err := client.PublishConfig(vo.ConfigParam{
DataId: localConfigTest.DataId,
DataId: "MultipleClients",
Group: localConfigTest.Group,
Content: localConfigTest.Content})

Expand All @@ -512,7 +512,7 @@ func TestListen(t *testing.T) {
t.Run("TestListenConfigWithMultipleClientsMultipleConfig", func(t *testing.T) {
ch := make(chan string)
listenConfigParam := vo.ConfigParam{
DataId: localConfigTest.DataId,
DataId: "MultipleClientsMultipleConfig",
Group: localConfigTest.Group,
OnChange: func(namespace, group, dataId, data string) {
fmt.Println("group:" + group + ", dataId:" + dataId + ", data:" + data)
Expand All @@ -528,7 +528,7 @@ func TestListen(t *testing.T) {
client1.ListenConfig(listenConfigParam)

success, err := client.PublishConfig(vo.ConfigParam{
DataId: localConfigTest.DataId,
DataId: "MultipleClientsMultipleConfig",
Group: localConfigTest.Group,
Content: localConfigTest.Content})

Expand All @@ -552,22 +552,21 @@ func TestCancelListenConfig(t *testing.T) {
client := cretateConfigClientTest()
var err error
var success bool
var context, context1 string
var context string
listenConfigParam := vo.ConfigParam{
DataId: "dataId",
DataId: "CancelOne",
Group: "group",
OnChange: func(namespace, group, dataId, data string) {
fmt.Println("group:" + group + ", dataId:" + dataId + ", data:" + data)
context = data
},
}

listenConfigParam1 := vo.ConfigParam{
DataId: "dataId1",
DataId: "CancelOne1",
Group: "group1",
OnChange: func(namespace, group, dataId, data string) {
fmt.Println("group1:" + group + ", dataId1:" + dataId + ", data:" + data)
context1 = data
context = data
},
}
go func() {
Expand All @@ -582,14 +581,14 @@ func TestCancelListenConfig(t *testing.T) {
for i := 1; i <= 5; i++ {
go func() {
success, err = client.PublishConfig(vo.ConfigParam{
DataId: "dataId",
DataId: "CancelOne",
Group: "group",
Content: "abcd" + strconv.Itoa(i)})
}()

go func() {
success, err = client.PublishConfig(vo.ConfigParam{
DataId: "dataId1",
DataId: "CancelOne1",
Group: "group1",
Content: "abcd" + strconv.Itoa(i)})
}()
Expand All @@ -602,9 +601,7 @@ func TestCancelListenConfig(t *testing.T) {
assert.Nil(t, err)
assert.Equal(t, true, success)
}

assert.Equal(t, "abcd2", context)
assert.Equal(t, "abcd5", context1)
assert.Equal(t, "abcd5", context)
})
t.Run("TestCancelListenConfig", func(t *testing.T) {
var context string
Expand Down
1 change: 0 additions & 1 deletion example/config/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,4 @@ func main() {
PageSize: 10,
})
fmt.Printf("Search config:%+v \n", searchPage)

}

0 comments on commit 26e692c

Please sign in to comment.