Documentation
¶
Index ¶
- Constants
- func AssertEmpty(t TestT, object interface{}, targetName string) error
- func AssertEmptyFunc(t TestT, object interface{}, targetName string) func() error
- func AssertEqual(t TestT, expected interface{}, actual interface{}, targetName string) error
- func AssertEqualFunc(t TestT, expected interface{}, actual interface{}, targetName string) func() error
- func AssertEqualWithExpected(testExpect *CRUDTestExpect) func(TestT, *CRUDTestContext, interface{}) error
- func AssertFalse(t TestT, value bool, targetName string) error
- func AssertFalseFunc(t TestT, value bool, targetName string) func() error
- func AssertLen(t TestT, object interface{}, length int, targetName string) error
- func AssertLenFunc(t TestT, object interface{}, length int, targetName string) func() error
- func AssertNil(t TestT, object interface{}, targetName string) error
- func AssertNilFunc(t TestT, object interface{}, targetName string) func() error
- func AssertNotEmpty(t TestT, object interface{}, targetName string) error
- func AssertNotEmptyFunc(t TestT, object interface{}, targetName string) func() error
- func AssertNotNil(t TestT, object interface{}, targetName string) error
- func AssertNotNilFunc(t TestT, object interface{}, targetName string) func() error
- func AssertTrue(t TestT, value bool, targetName string) error
- func AssertTrueFunc(t TestT, value bool, targetName string) func() error
- func CleanupTestResources(ctx context.Context, caller sacloud.APICaller, namePrefix string) error
- func DoAsserts(funcs ...func() error) error
- func IsAccTest() bool
- func IsEnableAPITrace() bool
- func IsEnableHTTPTrace() bool
- func IsEnableTrace() bool
- func PreCheckEnvsFunc(envs ...string) func(TestT)
- func RandomName(strlen int, charSet string) string
- func ResourceName(name string) string
- func Run(t TestT, testCase *CRUDTestCase)
- func SingletonAPICaller() *sacloud.Client
- func TestZone() string
- type CRUDTestCase
- type CRUDTestContext
- type CRUDTestDeleteFunc
- type CRUDTestExpect
- type CRUDTestFunc
- type TestT
Constants ¶
const ( // CharSetAlphaNum アフファベット(小文字)+数値 CharSetAlphaNum = "abcdefghijklmnopqrstuvwxyz012346789" // CharSetAlpha アフファベット(小文字) CharSetAlpha = "abcdefghijklmnopqrstuvwxyz" )
const TestResourcePrefix = "libsacloud-test-"
TestResourcePrefix テスト時に作成するリソースの名称に付与するプレフィックス
このプレフィックスを持つリソースは受入テスト実行後に削除される
Variables ¶
This section is empty.
Functions ¶
func AssertEmpty ¶
AssertEmpty emptyチェック
func AssertEmptyFunc ¶
AssertEmptyFunc emptyチェック
func AssertEqual ¶
AssertEqual 値の比較
func AssertEqualFunc ¶
func AssertEqualFunc(t TestT, expected interface{}, actual interface{}, targetName string) func() error
AssertEqualFunc 値の比較
func AssertEqualWithExpected ¶
func AssertEqualWithExpected(testExpect *CRUDTestExpect) func(TestT, *CRUDTestContext, interface{}) error
AssertEqualWithExpected 項目ごとに除外設定のできる期待値との比較
func AssertFalse ¶
AssertFalse falseチェック
func AssertFalseFunc ¶
AssertFalseFunc falseチェック
func AssertLenFunc ¶
AssertLenFunc lengthのチェック
func AssertNilFunc ¶
AssertNilFunc nilチェック
func AssertNotEmpty ¶
AssertNotEmpty not emptyチェック
func AssertNotEmptyFunc ¶
AssertNotEmptyFunc not emptyチェック
func AssertNotNil ¶
AssertNotNil not nilチェック
func AssertNotNilFunc ¶
AssertNotNilFunc not nilチェック
func AssertTrueFunc ¶
AssertTrueFunc trueチェック
func CleanupTestResources ¶
CleanupTestResources 指定プレフィックスを持つリソースの削除を行う
TESTACC環境変数が設定されている場合のみ実施される
func IsEnableAPITrace ¶
func IsEnableAPITrace() bool
IsEnableAPITrace SAKURACLOUD_TRACE_API環境変数が指定されているか
func IsEnableHTTPTrace ¶
func IsEnableHTTPTrace() bool
IsEnableHTTPTrace SAKURACLOUD_TRACE_HTTP環境変数が指定されているか
func PreCheckEnvsFunc ¶
PreCheckEnvsFunc 指定の環境変数が指定されていなかった場合にテストをスキップするためのFuncを返す
func SingletonAPICaller ¶
SingletonAPICaller 環境変数からシングルトンAPICallerを作成する
Types ¶
type CRUDTestCase ¶
type CRUDTestCase struct { // PreCheck テスト実行 or スキップを判定するためのFunc PreCheck func(TestT) // APICallerのセットアップ用Func、テストケースごとに1回呼ばれる SetupAPICallerFunc func() sacloud.APICaller // Setup テスト前の準備(依存リソースの作成など)を行うためのFunc(省略可) Setup func(*CRUDTestContext, sacloud.APICaller) error // Create Create操作のテスト用Func(省略可) Create *CRUDTestFunc // Read Read操作のテスト用Func(必須) Read *CRUDTestFunc // Updates Update操作のテスト用Func(省略可) Updates []*CRUDTestFunc // Shutdown Delete操作の前のシャットダウン(省略可) Shutdown func(*CRUDTestContext, sacloud.APICaller) error // Delete Delete操作のテスト用Func(省略可) Delete *CRUDTestDeleteFunc // Cleanup APIで作成/変更したリソースなどのクリーンアップ用Func(省略化) Cleanup func(*CRUDTestContext, sacloud.APICaller) error // Parallel t.Parallelを呼ぶかのフラグ Parallel bool // IgnoreStartupWait リソース作成後の起動待ちを行わない IgnoreStartupWait bool }
CRUDTestCase CRUD操作テストケース
type CRUDTestContext ¶
type CRUDTestContext struct { // ID CRUDテスト対象リソースのID // // Create/Read/Updateの戻り値がidAccessorの場合に各操作の後で設定される ID types.ID // Values 一連のテスト中に共有したい値 // // 依存リソースのIDの保持などで利用する Values map[string]interface{} // LastValue 最後の操作での戻り値 LastValue interface{} // contains filtered or unexported fields }
CRUDTestContext CRUD操作テストでのコンテキスト、一連のテスト中に共有される
func (*CRUDTestContext) Deadline ¶
func (c *CRUDTestContext) Deadline() (deadline time.Time, ok bool)
Deadline context.Context実装
func (*CRUDTestContext) Done ¶
func (c *CRUDTestContext) Done() <-chan struct{}
Done context.Context実装
func (*CRUDTestContext) Value ¶
func (c *CRUDTestContext) Value(key interface{}) interface{}
Value context.Context実装
type CRUDTestDeleteFunc ¶
type CRUDTestDeleteFunc struct { // Func API操作を行うFunc Func func(*CRUDTestContext, sacloud.APICaller) error }
CRUDTestDeleteFunc CRUD操作テストのDeleteテスト用Func
type CRUDTestExpect ¶
type CRUDTestExpect struct { // ExpectValue CRUD操作実行後の期待値 ExpectValue interface{} // IgnoreFields比較時に無視する項目 IgnoreFields []string }
CRUDTestExpect CRUD操作(DELETE以外)テストでの期待値
func (*CRUDTestExpect) Prepare ¶
func (c *CRUDTestExpect) Prepare(actual interface{}) (interface{}, interface{})
Prepare テスト対象値を受け取り、比較可能な状態に加工した対象値と期待値を返す
type CRUDTestFunc ¶
type CRUDTestFunc struct { // Func API操作を行うFunc Func func(*CRUDTestContext, sacloud.APICaller) (interface{}, error) // CheckFunc 任意のチェックを行うためのFunc、省略可能。 CheckFunc func(TestT, *CRUDTestContext, interface{}) error // SkipExtractID Trueの場合Funcの戻り値からのID抽出(ioAddessor経由)を行わない SkipExtractID bool }
CRUDTestFunc CRUD操作(DELETE以外)テストでのテスト用Func
type TestT ¶
type TestT interface { Log(args ...interface{}) Logf(format string, args ...interface{}) Error(args ...interface{}) Errorf(format string, args ...interface{}) FailNow() Fatal(args ...interface{}) Skip(args ...interface{}) Skipf(format string, args ...interface{}) Name() string Parallel() }
TestT テストのライフサイクルを管理するためのインターフェース.
通常は*testing.Tを実装として利用する