This is an automated email from the ASF dual-hosted git repository.

tianxiaoliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-mesher.git


The following commit(s) were added to refs/heads/master by this push:
     new ee91feb  add duboo protocol UT (#110)
ee91feb is described below

commit ee91febabe40a2ca900fc5531da77ae600d7732b
Author: t-xinlin <[email protected]>
AuthorDate: Fri Apr 3 17:52:40 2020 +0800

    add duboo protocol UT (#110)
    
    Co-authored-by: “[email protected] <Happy100>
---
 proxy/config/config_test.go                | 16 +++++++++++
 proxy/protocol/dubbo/dubbo/respond_test.go | 45 ++++++++++++++++++++++++++++++
 2 files changed, 61 insertions(+)

diff --git a/proxy/config/config_test.go b/proxy/config/config_test.go
index 9cbd597..76fac98 100644
--- a/proxy/config/config_test.go
+++ b/proxy/config/config_test.go
@@ -72,3 +72,19 @@ func TestSetConfig(t *testing.T) {
        assert.Equal(t, "host", c.Plugin.DestinationResolver["http"])
        assert.Equal(t, "8800", c.HealthCheck[0].Port)
 }
+
+var egressFile = []byte(`
+egress:
+  infra: cse  # pilot or cse
+  address: http://istio-pilot.istio-system:15010
+  `)
+
+func TestGetEgressEndpoints(t *testing.T) {
+       config.Init()
+       c := config.GetEgressConfig()
+       if err := yaml.Unmarshal([]byte(egressFile), c); err != nil {
+               t.Error(err)
+       }
+
+       assert.Equal(t, "http://istio-pilot.istio-system:15010";, 
c.Egress.Address)
+}
diff --git a/proxy/protocol/dubbo/dubbo/respond_test.go 
b/proxy/protocol/dubbo/dubbo/respond_test.go
new file mode 100644
index 0000000..2c41e3b
--- /dev/null
+++ b/proxy/protocol/dubbo/dubbo/respond_test.go
@@ -0,0 +1,45 @@
+package dubbo
+
+import (
+       "github.com/stretchr/testify/assert"
+       "testing"
+)
+
+func TestDubboDubboRsp(t *testing.T) {
+       rsp := DubboRsp{}
+       rsp.Init()
+       assert.Equal(t, "0.0.0", rsp.mVersion)
+       assert.Equal(t, false, rsp.mEvent)
+       assert.Equal(t, "", rsp.mErrorMsg)
+       assert.Equal(t, int64(0), rsp.mID)
+       assert.Equal(t, Ok, rsp.mStatus)
+
+       // Value
+       rsp.SetValue("test")
+       assert.NotNil(t, rsp.GetValue())
+
+       // Attachments
+       m := make(map[string]string)
+       m["key_01"] = "value_01"
+       m["key_02"] = "value_02"
+       m["key_03"] = "value_03"
+       rsp.SetAttachments(m)
+       attch := rsp.GetAttachments()
+       assert.NotNil(t, attch)
+       assert.Equal(t, "value_03", attch["key_03"])
+
+       // ID
+       rsp.SetID(12345)
+       assert.Equal(t, int64(12345), rsp.GetID())
+
+       // Exception
+       rsp.SetException("Java Throw Exception")
+       assert.Equal(t, "Java Throw Exception", rsp.GetException())
+
+       // Msg
+       rsp.SetErrorMsg("Test error msg")
+       assert.Equal(t, "Test error msg", rsp.GetErrorMsg())
+
+       // IsHeartbeat
+       assert.Equal(t, false, rsp.IsHeartbeat())
+}

Reply via email to