im_test.go 1.1 KB
package im

import (
	"testing"
)

const (
	IM_SERVICE_ADDRESS = "https://api.netease.im/nimserver"
	IM_APP_KEY         = "be7c0639c10e6a69f86ce3b4fa8dc8ec" //"ebf3ae278ee1b346773b99be5080f6a9"
	IM_APP_SECRET      = "9c5b60346613"                     //"67ea92e1ea45"
)

var accid = "18860183051"

func TestCallCreate(t *testing.T) {
	InitImClient(IM_SERVICE_ADDRESS, IM_APP_KEY, IM_APP_SECRET)
	token, err := CallCreate(UserCreate{Accid: accid})
	if err != nil {
		t.Fatal(err)
	}
	if token == nil {
		t.Fatal("token is nil")
	}
	t.Log(token.Code, token.Info)
}

func TestCallRefreshToken(t *testing.T) {
	InitImClient(IM_SERVICE_ADDRESS, IM_APP_KEY, IM_APP_SECRET)
	token, err := CallRefreshToken(UserRefreshToken{Accid: accid})
	if err != nil {
		t.Fatal(err)
	}
	if token == nil {
		t.Fatal("token is nil")
	}
	t.Log(token.Code, token.Info)
}

func TestCallUpdate(t *testing.T) {
	InitImClient(IM_SERVICE_ADDRESS, IM_APP_KEY, IM_APP_SECRET)
	token, err := CallUpdate(UserUpdate{Accid: accid, Name: "tip tok"})
	if err != nil {
		t.Fatal(err)
	}
	if token == nil {
		t.Fatal("token is nil")
	}
	t.Log(token.Code)
}