Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error to decode RegisterUserKeys #96

Open
lucasdk3 opened this issue Dec 20, 2024 · 1 comment
Open

Error to decode RegisterUserKeys #96

lucasdk3 opened this issue Dec 20, 2024 · 1 comment

Comments

@lucasdk3
Copy link

image
Hi, i have a error when decode RegisterUserKeys, because response is a string not a map
{"status-code":500,"error-code":"CloudstackApiError","details":"json: cannot unmarshal string into Go value of type cloudstack.RegisterUserKeysResponse"}
image

@Pearl1594
Copy link
Contributor

Pearl1594 commented Dec 31, 2024

@lucasdk3 I wasn't able to reproduce this issue. I added some test data - https://github.com/apache/cloudstack-go/pull/99/files and tried running the RegisterUserKeys test using:

/sb/cloudstack-go$ /usr/local/go/bin/go test -timeout 30s -run ^TestUserService$/^RegisterUserKeys$ github.com/apache/cloudstack-go/v2/test
ok  	github.com/apache/cloudstack-go/v2/test	0.007s

And it successfully ran.

Just to validate if the test was actually being run, I tried to change the response structure to :

  "registerUserKeys": {
    "registeruserkeysresponse": {
        "apikey": "hNfJi2dO5kwD6gTtYoifqu_4CSI3FcTtxc4MydW24PdJalv8mfTGsf425twAdLrIKX5IewfqIfYDEumO6-yRaw",
        "secretkey": "zV8kAYlyY4H-rEDO-Ot-VVPjKteVcU4haQcdRarte9wuOUhko3uzcnnFqNii8xifcpbe0eWR6IHAXjVGB2m1Hw"
    } 
  }

And on re-running the test it failed - indicating that the test runs fine:

/sb/cloudstack-go$ /usr/local/go/bin/go test -timeout 30s -run ^TestUserService$/^RegisterUserKeys$ github.com/apache/cloudstack-go/v2/test
--- FAIL: TestUserService (0.00s)
    --- FAIL: TestUserService/RegisterUserKeys (0.00s)
        UserService_test.go:180: json: cannot unmarshal string into Go value of type cloudstack.RegisterUserKeysResponse
FAIL
FAIL	github.com/apache/cloudstack-go/v2/test	0.007s
FAIL

Can you please let us know if there's anything different that needs to be done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants