trials

package
v1.1.52 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2025 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const Timeout = time.Millisecond * 200 // 預設等待時間

Variables

This section is empty.

Functions

func FileCompare

func FileCompare(path string, expected []byte) bool

FileCompare 比對檔案內容與位元陣列資料

func FileExist

func FileExist(path string) bool

FileExist 檢查檔案是否存在

func MongoCompare

func MongoCompare[T any](database *mongo.Database, table, field, key string, expected *T, option ...cmp.Option) bool

MongoCompare 在mongo中比對資料是否相同

func MongoExist

func MongoExist(database *mongo.Database, table, field, key string) bool

MongoExist 在mongo中資料是否存在

func ProtoEqual added in v1.1.20

func ProtoEqual(expected, actual any, option ...cmp.Option) bool

ProtoEqual 訊息是否符合

func ProtoListContain added in v1.1.41

func ProtoListContain[T any](expected any, actual []T, option ...cmp.Option) bool

ProtoListContain 訊息列表是否包含指定訊息

func ProtoListEqual added in v1.1.41

func ProtoListEqual[T any](expected, actual []T, option ...cmp.Option) bool

ProtoListEqual 訊息列表是否符合

func ProtoListExist added in v1.1.41

func ProtoListExist(expected any, actual []proto.Message) bool

ProtoListExist 訊息列表是否包含指定類型

func RedisCompare

func RedisCompare[T any](client redis.Cmdable, key string, expected *T, option ...cmp.Option) bool

RedisCompare 在redis中比對資料是否相同

func RedisCompareList added in v1.1.49

func RedisCompareList[T any](client redis.Cmdable, key string, expected []*T, option ...cmp.Option) bool

RedisCompareList 在redis中比對列表是否相同

func RedisExist

func RedisExist(client redis.Cmdable, key string) bool

RedisExist 在redis中資料是否存在

func Restore

func Restore(catalog Catalog)

Restore 還原測試目錄, 依照以下流程執行

  • 工作目錄改為目錄資料中的原始路徑
  • 刪除目錄資料中的工作路徑及其所有內容

func Root

func Root() string

Root 取得當前路徑

func Shell

func Shell(m *testing.M, initialize, finalize func(), work string, from ...string) (result int)

Shell 測試框架處理, 依照以下流程執行

  • 使用 Prepare 準備測試目錄
  • 執行初始化處理
  • 執行單元測試
  • 執行結束處理
  • 使用 Restore 還原測試目錄
  • 回傳單元測試的結果編號, 可用此編號呼叫 os.Exit, 讓外部能夠獲得測試結果

func WaitTimeout

func WaitTimeout(duration ...time.Duration)

WaitTimeout 等待超時時間, 可以輸入等待時間, 預設等待200毫秒

Types

type Catalog

type Catalog struct {
	// contains filtered or unexported fields
}

Catalog 目錄資料

func Prepare

func Prepare(work string, from ...string) Catalog

Prepare 準備測試目錄, 依照以下流程執行

  • 工作目錄改為 work 指定的路徑, 必須是絕對路徑
  • 從 from 把資料複製過來
  • 回傳用於還原的目錄資料

Jump to

Keyboard shortcuts

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