| 67 | } |
| 68 | |
| 69 | func TestClient_List(t *testing.T) { |
| 70 | assert := assert.New(t) |
| 71 | now := time.Now() |
| 72 | cli := &context.ClientContext{ |
| 73 | Namespace: "$unittest", |
| 74 | ID: 1, |
| 75 | RemoteAddr: "127.0.0.1", |
| 76 | DB: &db.DB{Namespace: "$unittest", ID: 0}, |
| 77 | Created: now, |
| 78 | Updated: now, |
| 79 | } |
| 80 | serv := &context.ServerContext{} |
| 81 | serv.Clients.Store(cli.RemoteAddr, cli) |
| 82 | |
| 83 | out := bytes.NewBuffer(nil) |
| 84 | ctx := &Context{ |
| 85 | Name: "client", |
| 86 | Args: []string{"list"}, |
| 87 | In: nil, |
| 88 | Out: out, |
| 89 | Context: context.New(cli, serv), |
| 90 | } |
| 91 | |
| 92 | Client(ctx) |
| 93 | |
| 94 | assert.Contains(out.String(), "id=1 addr=127.0.0.1") |
| 95 | } |