go-gitea/go-sdk

AdminCreateUser fails with json: cannot unmarshal array into Go value of type map[string]interface {}

klauern opened this issue · 5 comments

Similar to #40, I noticed this when trying to use this SDK to write a Terraform provider plugin.

package gitea

import (
	"fmt"
	"testing"

	"code.gitea.io/sdk/gitea"
)

func TestGiteaUserCreate(t *testing.T) {
	client := gitea.NewClient("http://localhost:3000", "978fd3ee4f71d6cf8a87556201d37293d719230d")
	user, err := client.AdminCreateUser(gitea.CreateUserOption{
		Email:     "random@example.com",
		LoginName: "random",
		Username:  "random",
	})

	if err != nil {
		t.Fatal(err)
	}

	fmt.Printf("%#v", user)

}

Output of test:

Parsed Response for path /admin/users
--- FAIL: TestGiteaUserCreate (0.02s)
        gitea_api_test.go:19: json: cannot unmarshal array into Go value of type map[string]interface {}
FAIL
FAIL    github.com/klauern/terraform-gitea-provider/gitea       0.104s
lunny commented

Is this duplicated with #40

Is it using the same underlying JSON Decoder, or is it a separate struct for the response?

lunny commented

@klauern how about add your test on this project and let host and secret as an environment?

That's easy enough.