Documentation ¶
Index ¶
- func NewActionList(cl Client) []gentest.Actor
- func NewRMessage(name string, text string, done chan bool) *rMessage
- func NewRestActionList(cl *RestClient) []gentest.Actor
- func RandomString(maxlen int) string
- func RemoveTime(s string) string
- type Client
- type ClientData
- type HTTPClient
- func (cl *HTTPClient) Block(name string)
- func (cl *HTTPClient) CheckResponse()
- func (cl *HTTPClient) GetMessages()
- func (cl *HTTPClient) Join(rmName string)
- func (cl *HTTPClient) List()
- func (cl *HTTPClient) Login()
- func (cl *HTTPClient) Name() string
- func (cl *HTTPClient) Send(msg string)
- func (cl *HTTPClient) UnBlock(name string)
- func (cl *HTTPClient) Update()
- func (cl *HTTPClient) Who(rmName string)
- type Lgn
- type RestClient
- type Result
- func (r *Result) Add(text string)
- func (r *Result) Block(name string)
- func (r *Result) GetRoom(rm string) *room
- func (r *Result) IsBlocked(name string) bool
- func (r *Result) Join(rm string)
- func (r *Result) JoinSend(text string)
- func (r *Result) List()
- func (r *Result) RestGet(name string)
- func (r *Result) RestSend(message, room string)
- func (r *Result) Room() string
- func (r *Result) Send(text string)
- func (r *Result) UnBlock(name string) bool
- func (r *Result) Who(name string)
- type ResultHandler
- type SharedClient
- type TelnetClient
- func (cl *TelnetClient) Block(name string)
- func (cl *TelnetClient) CheckResponse()
- func (cl *TelnetClient) GetMessages()
- func (cl *TelnetClient) Join(rm string)
- func (cl *TelnetClient) List()
- func (cl *TelnetClient) Login()
- func (cl TelnetClient) Name() string
- func (cl *TelnetClient) Send(m string)
- func (cl *TelnetClient) UnBlock(name string)
- func (cl *TelnetClient) Update()
- func (cl *TelnetClient) Who(rm string)
- type TestClient
- type TestMessage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewActionList ¶
NewActionList creates a slice of the clients actors.
func NewRMessage ¶
NewRMessage creates a new rMessage.
func NewRestActionList ¶
func NewRestActionList(cl *RestClient) []gentest.Actor
NewRestActionList creates a slice of rest client actors.
func RandomString ¶
RandomString returns a random string of maxlen > len > 0 made up of upper and lower case letters and/or numbers.
func RemoveTime ¶
RemoveTime removes the time from a message string from the server to make it easier to compare with the results.
Types ¶
type Client ¶
type Client interface { Login() Block(string) UnBlock(string) Who(string) List() Join(string) Send(string) CheckResponse() Name() string Update() }
Client is an interface for using the ChatTest including all the functions that it calls
type ClientData ¶
type ClientData struct { Rooms []string Names []string Clients []SharedClient }
ClientData is an object for passing the necessary data into the actions.
type HTTPClient ¶
type HTTPClient struct {
// contains filtered or unexported fields
}
HTTPClient is a Client used for testing the server's HTTP side.
func NewHTTPClient ¶
func NewHTTPClient(name string, ip string, port string, rh *ResultHandler, t *testing.T) *HTTPClient
NewHTTPClient returns a new http client.
func (*HTTPClient) Block ¶
func (cl *HTTPClient) Block(name string)
Block adds the name to client's block list and updates its results.
func (*HTTPClient) CheckResponse ¶
func (cl *HTTPClient) CheckResponse()
CheckResponse compares the clients messages recieved to those expected by its Results object and fails the test if they don't match. It also panics to short circuit long tests when it goes out of sync.
func (*HTTPClient) GetMessages ¶
func (cl *HTTPClient) GetMessages()
GetMessages retrieves the clients current messages from the server.
func (*HTTPClient) Join ¶
func (cl *HTTPClient) Join(rmName string)
Join adds the client to a room and updates its results.
func (*HTTPClient) List ¶
func (cl *HTTPClient) List()
List retrieves from the server a list of current rooms and updates its results.
func (*HTTPClient) Login ¶
func (cl *HTTPClient) Login()
Login connects the client to the server and sets the clients token for future requests.
func (*HTTPClient) Send ¶
func (cl *HTTPClient) Send(msg string)
Send transmits the message to the clients room and updates its results.
func (*HTTPClient) UnBlock ¶
func (cl *HTTPClient) UnBlock(name string)
Unblock removes clients matching name from this client's block list and updates its results.
func (*HTTPClient) Update ¶
func (cl *HTTPClient) Update()
Update runs GetMessage to update the client's messages from the server.
func (*HTTPClient) Who ¶
func (cl *HTTPClient) Who(rmName string)
Who retrieves from the server a list of the clients currently in the room and updates its results.
type RestClient ¶
type RestClient struct {
// contains filtered or unexported fields
}
RestClient is a type of client for testing the servers REST api.
func NewRestClient ¶
func NewRestClient(name string, ip string, port string, rh *ResultHandler, t *testing.T) *RestClient
NewRestClient returns a new RestClient.
func (*RestClient) CheckResponse ¶
func (cl *RestClient) CheckResponse()
CheckResponse checks to see if the next message in the clients messages list is equal to m.
func (*RestClient) Get ¶
func (cl *RestClient) Get(room string)
Get gets the messages from the room.
func (*RestClient) Send ¶
func (cl *RestClient) Send(m, room string)
Send sends the message to the room.
func (*RestClient) Update ¶
func (cl *RestClient) Update()
Update is empty so that a rest client can meet the Client interface. A rest client can not be updated because it doesn't expect anything specific from the server.
type Result ¶
type Result struct { Results []string // contains filtered or unexported fields }
Result is an object for keeping track of what responses the client should be getting from the server. Result.Results contains all of the messages that should have been sent to the client.
func NewResult ¶
func NewResult(name string, rh *ResultHandler) *Result
NewResult creates a new result object without a chattest.
func (*Result) Add ¶
Add adds the string to the Result of only this Result not the others in the same room.
func (*Result) GetRoom ¶
GetRoom returns a room with name matching rm. Unlike join it will not create one if it doesn't exist, returning nil instead.
func (*Result) Join ¶
Join changes the results room to the with name == rm and updates its channels.
func (*Result) JoinSend ¶
JoinSend adds the string to the results of everyone in the same room as the sender even if blocking the sender. Primarily for use with join room messages.
func (*Result) List ¶
func (r *Result) List()
List udpates the result for a list action, adding the list of current rooms in the Result.
func (*Result) Send ¶
Send adds the string to the results of everyone in the same room as the sender.
type ResultHandler ¶
type ResultHandler struct {
// contains filtered or unexported fields
}
ResultHandler manages the result rooms and the interactions between the results of different clients.
func NewResultHandler ¶
func NewResultHandler() *ResultHandler
NewResultHandler creates a new ResultHandler.
type SharedClient ¶
type SharedClient interface {}
SharedClient is an interface for use in the shared ClientData
type TelnetClient ¶
type TelnetClient struct {
// contains filtered or unexported fields
}
TelnetClient is a Client used for testing the server's telnet side.
func NewTelnetClient ¶
func NewTelnetClient(name string, ip string, port string, rh *ResultHandler, t *testing.T) *TelnetClient
NewTelnetClient returns a new telnet client.
func (*TelnetClient) Block ¶
func (cl *TelnetClient) Block(name string)
Block adds name to client's block list and updates its results.
func (*TelnetClient) CheckResponse ¶
func (cl *TelnetClient) CheckResponse()
CheckResponse compares the clients messages recieved to those expected by its Results object and fails the test if they don't match. It also panics to short circuit long tests when it goes out of sync.
func (*TelnetClient) GetMessages ¶
func (cl *TelnetClient) GetMessages()
GetMessages reads the messages from the server and stores them in the clients messages
func (*TelnetClient) Join ¶
func (cl *TelnetClient) Join(rm string)
Join adds the client to a room and updates its results.
func (*TelnetClient) List ¶
func (cl *TelnetClient) List()
List retrieves from the server a list of current rooms and updates its results.
func (*TelnetClient) Login ¶
func (cl *TelnetClient) Login()
Login connects the client to the server and starts GetMessages, its messages retrieval method.
func (*TelnetClient) Send ¶
func (cl *TelnetClient) Send(m string)
Send transmits the message to the clients room and updates its results.
func (*TelnetClient) UnBlock ¶
func (cl *TelnetClient) UnBlock(name string)
UnBlock removes clients matching name from this client's block list and updates its results.
func (*TelnetClient) Update ¶
func (cl *TelnetClient) Update()
Update is a method that runs checkupdate to match with the Client interface.
func (*TelnetClient) Who ¶
func (cl *TelnetClient) Who(rm string)
Who retrieves from the server a list of the clients currently in the room and updates its results.
type TestClient ¶
type TestClient struct {
// contains filtered or unexported fields
}
TestClient can hold either a regular client or a rest client. The client that it uses is determined by its action.
func NewTestClient ¶
func NewTestClient(cl Client) *TestClient
NewTestClient returns a test client with default equal weights for its actions.
func NewTestClientWithWeights ¶
func NewTestClientWithWeights(cl Client, weights []int) *TestClient
NewTestClientWithWeights returns a test client with weighted action probabilites. The weights slice should contain int for the weights in the order of join, send, block, unblock, list, who.
func NewTestRestClient ¶
func NewTestRestClient(cl *RestClient) *TestClient
NewTestRestClient returns a test client that uses the rest inteface with default weights for its actions.
func (*TestClient) Client ¶
func (tc *TestClient) Client() SharedClient
Client() returns the TestClient's Client.
func (*TestClient) Do ¶
func (tc *TestClient) Do(shared interface{}) string
Do is a method that allows the test client to meet the Actor interface. It will run a random client action from its action list.
type TestMessage ¶
TestMessage is a simple message implementation for use by the RestClient in composing messages for transmission to the server.
func (TestMessage) Result ¶
func (t TestMessage) Result() string
Result returns a string of the message in the format used by the server.