maxapi: refactor reward tests

This commit is contained in:
c9s 2023-04-12 16:32:56 +08:00
parent 9dab2470ef
commit a84a22bc2d
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -18,35 +18,26 @@ func TestRewardService_GetRewardsRequest(t *testing.T) {
client := NewRestClient(ProductionAPIURL)
client.Auth(key, secret)
req := client.RewardService.NewGetRewardsRequest()
rewards, err := req.Do(ctx)
assert.NoError(t, err)
assert.NotNil(t, rewards)
assert.NotEmpty(t, rewards)
t.Run("v2/rewards", func(t *testing.T) {
req := client.RewardService.NewGetRewardsRequest()
rewards, err := req.Do(ctx)
assert.NoError(t, err)
assert.NotNil(t, rewards)
assert.NotEmpty(t, rewards)
t.Logf("rewards: %+v", rewards)
})
t.Logf("rewards: %+v", rewards)
}
func TestRewardService_GetRewardsOfTypeRequest(t *testing.T) {
key, secret, ok := integrationTestConfigured(t, "MAX")
if !ok {
t.SkipNow()
}
ctx := context.Background()
client := NewRestClient(ProductionAPIURL)
client.Auth(key, secret)
req := client.RewardService.NewGetRewardsOfTypeRequest(RewardCommission)
rewards, err := req.Do(ctx)
assert.NoError(t, err)
assert.NotNil(t, rewards)
assert.NotEmpty(t, rewards)
t.Logf("rewards: %+v", rewards)
for _, reward := range rewards {
assert.Equal(t, RewardCommission, reward.Type)
}
t.Run("v2/rewards with type", func(t *testing.T) {
req := client.RewardService.NewGetRewardsOfTypeRequest(RewardCommission)
rewards, err := req.Do(ctx)
assert.NoError(t, err)
assert.NotNil(t, rewards)
assert.NotEmpty(t, rewards)
t.Logf("rewards: %+v", rewards)
for _, reward := range rewards {
assert.Equal(t, RewardCommission, reward.Type)
}
})
}