testutils

package
v0.0.0-...-265e2c9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2025 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package testutils provides utility functions for testing Zulip API clients.

Index

Constants

View Source
const (
	TestSite              = "http://localhost:9991"
	TestOwnerUsername     = "[email protected]"
	TestAdminUsername     = "[email protected]"
	TestModeratorUsername = "[email protected]"
	TestGuestUsername     = "[email protected]"
	TestNormalUsername    = "[email protected]"
	OtherNormalUsername   = "[email protected]"
	DeactivateTestUser    = "[email protected]"
)

Constants for test users.

Variables

View Source
var (
	OwnerClient     = namedClient{/* contains filtered or unexported fields */}
	AdminClient     = namedClient{/* contains filtered or unexported fields */}
	ModeratorClient = namedClient{/* contains filtered or unexported fields */}
	NormalClient    = namedClient{/* contains filtered or unexported fields */}
	BotClient       = namedClient{/* contains filtered or unexported fields */}
	AllClients      = []namedClient{OwnerClient, AdminClient, ModeratorClient, NormalClient}
)

named clients for testing.

Functions

func CreateDirectMessage

func CreateDirectMessage(t *testing.T, apiClient client.Client, to int64) int64

func CreateRandomChannel

func CreateRandomChannel(t *testing.T, apiClient client.Client, subscribers ...int64) (string, int64)

func CreateRandomUserGroup

func CreateRandomUserGroup(t *testing.T, apiClient client.Client, members ...int64) int64

func GetAdminClient

func GetAdminClient(t *testing.T) client.Client

func GetBotClient

func GetBotClient(t *testing.T) client.Client

func GetChannelWithAllClients

func GetChannelWithAllClients(t *testing.T) (string, int64)

func GetFeatureLevel

func GetFeatureLevel(t *testing.T) int

func GetGuestClient

func GetGuestClient(t *testing.T) client.Client

func GetModeratorClient

func GetModeratorClient(t *testing.T) client.Client

func GetNormalClient

func GetNormalClient(t *testing.T) client.Client

func GetOtherNormalClient

func GetOtherNormalClient(t *testing.T) client.Client

func GetOwnerClient

func GetOwnerClient(t *testing.T) client.Client

func GetTestClient

func GetTestClient(t *testing.T, username string) (*z.RC, client.Client)

func GetUserEmail

func GetUserEmail(t *testing.T, apiClient client.Client) string

func GetUserID

func GetUserID(t *testing.T, apiClient client.Client) int64

func RequireFeatureLevel

func RequireFeatureLevel(t *testing.T, minLevel int)

func RunForAdminAndOwnerClients

func RunForAdminAndOwnerClients(t *testing.T, fn func(*testing.T, client.Client))

func RunForAllClients

func RunForAllClients(t *testing.T, fn func(*testing.T, client.Client))

func RunForClients

func RunForClients(t *testing.T, clients []namedClient, fn func(*testing.T, client.Client))

func SendChannelMessage

func SendChannelMessage(t *testing.T, apiClient client.Client, channelID int64, topic, content string) int64

func UniqueName

func UniqueName(prefix string) string

func UploadFileForTest

func UploadFileForTest(ctx context.Context, t *testing.T, apiClient client.Client) *messages.UploadFileResponse

Types

type ChannelMessage

type ChannelMessage struct {
	ChannelID int64
	Topic     string
	MessageID int64
}

func CreateChannelMessage

func CreateChannelMessage(t *testing.T, apiClient client.Client, channelID int64) ChannelMessage

type UserInfo

type UserInfo struct {
	APIKey string `json:"api_key"`
	EMail  string `json:"email"`
	UserID int    `json:"user_id"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL