123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- package cli
- import (
- "reflect"
- "sync"
- "testing"
- )
- func TestContext_Bind(t *testing.T) {
- type fields struct {
- ID int32
- CmdStr string
- Args []string
- locker sync.RWMutex
- Values map[string]interface{}
- response *Response
- }
- type args struct {
- i interface{}
- }
- tests := []struct {
- name string
- fields fields
- args args
- wantErr bool
- }{
- // TODO: Add test cases.
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- ctx := &Context{
- ID: tt.fields.ID,
- CmdStr: tt.fields.CmdStr,
- Args: tt.fields.Args,
- locker: tt.fields.locker,
- Values: tt.fields.Values,
- response: tt.fields.response,
- }
- if err := ctx.Bind(tt.args.i); (err != nil) != tt.wantErr {
- t.Errorf("Bind() error = %v, wantErr %v", err, tt.wantErr)
- }
- })
- }
- }
- func TestContext_Error(t *testing.T) {
- type fields struct {
- ID int32
- CmdStr string
- Args []string
- locker sync.RWMutex
- Values map[string]interface{}
- response *Response
- }
- type args struct {
- code int
- msg string
- }
- tests := []struct {
- name string
- fields fields
- args args
- wantErr bool
- }{
- // TODO: Add test cases.
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- ctx := &Context{
- ID: tt.fields.ID,
- CmdStr: tt.fields.CmdStr,
- Args: tt.fields.Args,
- locker: tt.fields.locker,
- Values: tt.fields.Values,
- response: tt.fields.response,
- }
- if err := ctx.Error(tt.args.code, tt.args.msg); (err != nil) != tt.wantErr {
- t.Errorf("Error() error = %v, wantErr %v", err, tt.wantErr)
- }
- })
- }
- }
- func TestContext_Success(t *testing.T) {
- type fields struct {
- ID int32
- CmdStr string
- Args []string
- locker sync.RWMutex
- Values map[string]interface{}
- response *Response
- }
- type args struct {
- i interface{}
- }
- tests := []struct {
- name string
- fields fields
- args args
- wantErr bool
- }{
- // TODO: Add test cases.
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- ctx := &Context{
- ID: tt.fields.ID,
- CmdStr: tt.fields.CmdStr,
- Args: tt.fields.Args,
- locker: tt.fields.locker,
- Values: tt.fields.Values,
- response: tt.fields.response,
- }
- if err := ctx.Success(tt.args.i); (err != nil) != tt.wantErr {
- t.Errorf("Success() error = %v, wantErr %v", err, tt.wantErr)
- }
- })
- }
- }
- func TestRef(t *testing.T) {
- type x struct {
- A string
- }
- refVal := reflect.Indirect(reflect.ValueOf(&x{A: "xxx"}))
- t.Log(refVal.Field(0).Kind())
- t.Log(refVal.Type().Field(0).Name)
- }
|