Skip to content
Snippets Groups Projects
Commit 344d0a1b authored by fangyincheng's avatar fangyincheng Committed by GitHub
Browse files

Merge pull request #304 from zouyx/feature/deleteMockJson

Add : delete mock json in test case of apollo
parents c8f57d96 bfa2eca7
No related branches found
No related tags found
No related merge requests found
...@@ -21,9 +21,11 @@ import ( ...@@ -21,9 +21,11 @@ import (
"fmt" "fmt"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"os"
"strings" "strings"
"sync" "sync"
"testing" "testing"
"time"
) )
import ( import (
...@@ -171,6 +173,7 @@ func Test_GetConfig(t *testing.T) { ...@@ -171,6 +173,7 @@ func Test_GetConfig(t *testing.T) {
mapContent, err := configuration.Parser().Parse(configs) mapContent, err := configuration.Parser().Parse(configs)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, "ikurento.com", mapContent["application.organization"]) assert.Equal(t, "ikurento.com", mapContent["application.organization"])
deleteMockJson(t)
} }
func Test_GetConfigItem(t *testing.T) { func Test_GetConfigItem(t *testing.T) {
...@@ -180,6 +183,7 @@ func Test_GetConfigItem(t *testing.T) { ...@@ -180,6 +183,7 @@ func Test_GetConfigItem(t *testing.T) {
configuration.SetParser(&parser.DefaultConfigurationParser{}) configuration.SetParser(&parser.DefaultConfigurationParser{})
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, "ikurento.com", configs) assert.Equal(t, "ikurento.com", configs)
deleteMockJson(t)
} }
func initMockApollo(t *testing.T) *apolloConfiguration { func initMockApollo(t *testing.T) *apolloConfiguration {
...@@ -216,6 +220,7 @@ func TestAddListener(t *testing.T) { ...@@ -216,6 +220,7 @@ func TestAddListener(t *testing.T) {
listener.wg.Wait() listener.wg.Wait()
assert.Equal(t, "registries.hangzhouzk.username", listener.event) assert.Equal(t, "registries.hangzhouzk.username", listener.event)
assert.Greater(t, listener.count, 0) assert.Greater(t, listener.count, 0)
deleteMockJson(t)
} }
func TestRemoveListener(t *testing.T) { func TestRemoveListener(t *testing.T) {
...@@ -244,6 +249,7 @@ func TestRemoveListener(t *testing.T) { ...@@ -244,6 +249,7 @@ func TestRemoveListener(t *testing.T) {
}) })
assert.Equal(t, listenerCount, 0) assert.Equal(t, listenerCount, 0)
assert.Equal(t, listener.count, 0) assert.Equal(t, listener.count, 0)
deleteMockJson(t)
} }
type apolloDataListener struct { type apolloDataListener struct {
...@@ -260,3 +266,10 @@ func (l *apolloDataListener) Process(configType *config_center.ConfigChangeEvent ...@@ -260,3 +266,10 @@ func (l *apolloDataListener) Process(configType *config_center.ConfigChangeEvent
l.count++ l.count++
l.event = configType.Key l.event = configType.Key
} }
func deleteMockJson(t *testing.T) {
//because the file write in another goroutine,so have a break ...
time.Sleep(100 * time.Millisecond)
remove := os.Remove("mockDubbog.properties.json")
t.Log("remove result:", remove)
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment