Cloudreve/pkg/filesystem/driver/onedrive/client_test.go

33 lines
598 B
Go
Raw Normal View History

2020-01-22 10:50:47 +08:00
package onedrive
2020-01-22 14:26:13 +08:00
import (
"testing"
model "github.com/cloudreve/Cloudreve/v3/models"
"github.com/stretchr/testify/assert"
2020-01-22 14:26:13 +08:00
)
2020-01-22 10:50:47 +08:00
func TestNewClient(t *testing.T) {
2020-01-22 14:26:13 +08:00
asserts := assert.New(t)
// getOAuthEndpoint失败
{
policy := model.Policy{
BaseURL: string([]byte{0x7f}),
}
res, err := NewClient(&policy)
asserts.Error(err)
asserts.Nil(res)
}
2020-01-22 10:50:47 +08:00
2020-01-22 14:26:13 +08:00
// 成功
{
policy := model.Policy{}
res, err := NewClient(&policy)
asserts.NoError(err)
asserts.NotNil(res)
asserts.NotNil(res.Credential)
asserts.NotNil(res.Endpoints)
asserts.NotNil(res.Endpoints.OAuthEndpoints)
}
2020-01-22 10:50:47 +08:00
}