fake

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	UserId   = 111
	UserName = "user_name"
)

Functions

This section is empty.

Types

type Engine

type Engine struct {
	User         *User
	Applications []*v1.Application
	Versions     []*v1.Version

	// MapのkeyにApplicationのIDを利用する
	Traffics map[string][]*v1.Traffic

	// GeneratedID 採番済みの最終ID
	//
	// DataStoreの各フィールドの値との整合性は確認されないため利用者側が管理する必要がある
	GeneratedVersionID int
	// contains filtered or unexported fields
}

Engine Fakeサーバであつかうダミーデータを表す

Serverに渡した後はDataStore内のデータを外部から操作しないこと

func NewEngine

func NewEngine() *Engine

func (*Engine) CreateApplication

func (engine *Engine) CreateApplication(reqBody *v1.PostApplicationBody) (*v1.Application, error)

func (*Engine) CreateUser

func (engine *Engine) CreateUser() error

func (*Engine) DeleteApplication

func (engine *Engine) DeleteApplication(id string) error

func (*Engine) DeleteVersion

func (engine *Engine) DeleteVersion(appId string, versionId string) error

func (*Engine) GetUser

func (engine *Engine) GetUser() error

func (*Engine) ListApplications

func (engine *Engine) ListApplications(param v1.ListApplicationsParams) (*v1.HandlerListApplications, error)

func (*Engine) ListTraffics

func (engine *Engine) ListTraffics(appId string) (*v1.HandlerListTraffics, error)

func (*Engine) ListVersions

func (engine *Engine) ListVersions(appId string, param v1.ListApplicationVersionsParams) (*v1.HandlerListVersions, error)

func (*Engine) ReadApplication

func (engine *Engine) ReadApplication(id string) (*v1.Application, error)

func (*Engine) ReadPacketFilter added in v0.4.0

func (engine *Engine) ReadPacketFilter(appId string) (*v1.HandlerGetPacketFilter, error)

func (*Engine) ReadVersion

func (engine *Engine) ReadVersion(appId string, versionId string) (*v1.HandlerGetVersion, error)

func (*Engine) UpdateApplication

func (engine *Engine) UpdateApplication(id string, reqBody *v1.PatchApplicationBody) (*v1.HandlerPatchApplication, error)

func (*Engine) UpdatePacketFilter added in v0.4.0

func (engine *Engine) UpdatePacketFilter(appId string, body *v1.PatchPacketFilter) (*v1.HandlerPatchPacketFilter, error)

func (*Engine) UpdateTraffic

func (engine *Engine) UpdateTraffic(appId string, body *v1.PutTrafficsBody) (*v1.HandlerPutTraffics, error)

type Error

type Error struct {
	Type     ErrorType
	Resource string
	Id       interface{}
	// contains filtered or unexported fields
}

Error fake.Engineが出力するエラー型

func (*Error) Error

func (e *Error) Error() string

Error errorインターフェースの実装

type ErrorType

type ErrorType int

ErrorType fakeサーバが扱うエラーの種別

const (
	ErrorTypeUnknown        ErrorType = iota // 未知のエラー
	ErrorTypeInvalidRequest                  // Bad Request
	ErrorTypeNotFound                        // Not Found
	ErrorTypeConflict                        // Conflict
)

func (ErrorType) String

func (e ErrorType) String() string

String Stringer実装

type User

type User struct {
	Id   int
	Name string
}

API上でUserの定義は存在しないが、ユーザーのサインアップを管理するために定義する

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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