Merge pull request #427 from swordqiu/hotfix/qj-fix-cloudcommon-policy-test-error

Hotfix/qj fix cloudcommon policy test error
This commit is contained in:
yunion-ci-robot
2019-04-17 10:18:10 +08:00
committed by GitHub
7 changed files with 119 additions and 13 deletions
+36 -4
View File
@@ -14,7 +14,6 @@
package policy
/*
import (
"testing"
@@ -35,7 +34,7 @@ func TestSerialize(t *testing.T) {
jsonEmb := jsonutils.Marshal(&emb)
t.Logf("%s", jsonEmb)
t.Logf("json: %s", jsonEmb)
nemb := SEmbed{}
@@ -44,6 +43,39 @@ func TestSerialize(t *testing.T) {
t.Errorf("fail to unmarshal: %s", err)
} else {
jsonEmb2 := jsonutils.Marshal(&nemb)
t.Logf("%s", jsonEmb2)
t.Logf("unmarshal: %s", jsonEmb2)
}
}*/
}
func TestSerialize2(t *testing.T) {
type SEmbed struct {
UserCred mcclient.TokenCredential
}
type SUnEmbed struct {
UserCred struct {
TokenCredential mcclient.TokenCredential
}
}
token := &SPolicyTokenCredential{
&mcclient.SSimpleToken{
User: "Test",
},
}
emb := SEmbed{}
emb.UserCred = token
jsonEmb := jsonutils.Marshal(&emb)
t.Logf("json: %s", jsonEmb)
nemb := SUnEmbed{}
err := jsonEmb.Unmarshal(&nemb)
if err != nil {
t.Errorf("fail to unmarshal: %s", err)
} else {
jsonEmb2 := jsonutils.Marshal(&nemb)
t.Logf("unmarshal: %s", jsonEmb2)
}
}