Skip to content

Commit

Permalink
Merge pull request #42 from leancloud/cloud-init
Browse files Browse the repository at this point in the history
🚚 Move LeanEngine features into `leancloud.Engine`
  • Loading branch information
jysperm authored Oct 20, 2021
2 parents 6df03a9 + f93a751 commit ebeb27f
Show file tree
Hide file tree
Showing 9 changed files with 458 additions and 439 deletions.
7 changes: 7 additions & 0 deletions leancloud/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ import (
"testing"
)

var client *Client

func init() {
client = NewEnvClient()
Engine.Init(client)
}

func TestNewClient(t *testing.T) {
appID, appKey, masterKey, serverURL := os.Getenv("LEANCLOUD_APP_ID"), os.Getenv("LEANCLOUD_APP_KEY"), os.Getenv("LEANCLOUD_APP_MASTER_KEY"), os.Getenv("LEANCLOUD_API_SERVER")
options := &ClientOptions{
Expand Down
299 changes: 0 additions & 299 deletions leancloud/cloud.go

This file was deleted.

6 changes: 3 additions & 3 deletions leancloud/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -598,14 +598,14 @@ func decodeObject(fields interface{}) (*Object, error) {
var decodedCreatedAt, decodedUpdatedAt time.Time
var ok bool

if decodedFields["objectId"] != "" {
if decodedFields["objectId"] != "" && decodedFields["objectId"] != nil {
objectID, ok = decodedFields["objectId"].(string)
if !ok {
return nil, fmt.Errorf("unexpected error when parse objectId: want type string but %v", reflect.TypeOf(decodedFields["objectId"]))
}
}

if decodedFields["createdAt"] != "" {
if decodedFields["createdAt"] != "" && decodedFields["createdAt"] != nil {
createdAt, ok = decodedFields["createdAt"].(string)
if !ok {
return nil, fmt.Errorf("unexpected error when parse createdAt: want type string but %v", reflect.TypeOf(decodedFields["createdAt"]))
Expand All @@ -617,7 +617,7 @@ func decodeObject(fields interface{}) (*Object, error) {
decodedFields["createdAt"] = decodedCreatedAt
}

if decodedFields["updatedAt"] != "" {
if decodedFields["updatedAt"] != "" && decodedFields["updatedAt"] != nil {
updatedAt, ok = decodedFields["updatedAt"].(string)
if !ok {
if decodedFields["updatedAt"] == nil {
Expand Down
Loading

0 comments on commit ebeb27f

Please sign in to comment.