repo
stringlengths 5
67
| sha
stringlengths 40
40
| path
stringlengths 4
234
| url
stringlengths 85
339
| language
stringclasses 6
values | split
stringclasses 3
values | doc
stringlengths 3
51.2k
| sign
stringlengths 5
8.01k
| problem
stringlengths 13
51.2k
| output
stringlengths 0
3.87M
|
---|---|---|---|---|---|---|---|---|---|
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/timebee/timebeefactory.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/timebee/timebeefactory.go#L112-L122 | go | train | // Events describes the available events provided by this Bee. | func (factory *TimeBeeFactory) Events() []bees.EventDescriptor | // Events describes the available events provided by this Bee.
func (factory *TimeBeeFactory) Events() []bees.EventDescriptor | {
events := []bees.EventDescriptor{
{
Namespace: factory.Name(),
Name: "time",
Description: "The time has come ...",
Options: []bees.PlaceholderDescriptor{},
},
}
return events
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | api/resources/hives/hives_get.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/api/resources/hives/hives_get.go#L54-L69 | go | train | // GetByIDs sends out all items matching a set of IDs | func (r *HiveResource) GetByIDs(ctx smolder.APIContext, request *restful.Request, response *restful.Response, ids []string) | // GetByIDs sends out all items matching a set of IDs
func (r *HiveResource) GetByIDs(ctx smolder.APIContext, request *restful.Request, response *restful.Response, ids []string) | {
resp := HiveResponse{}
resp.Init(ctx)
for _, id := range ids {
hive := bees.GetFactory(id)
if hive == nil {
r.NotFound(request, response)
return
}
resp.AddHive(hive)
}
resp.Send(response)
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | api/resources/hives/hives_get.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/api/resources/hives/hives_get.go#L72-L88 | go | train | // Get sends out items matching the query parameters | func (r *HiveResource) Get(ctx smolder.APIContext, request *restful.Request, response *restful.Response, params map[string][]string) | // Get sends out items matching the query parameters
func (r *HiveResource) Get(ctx smolder.APIContext, request *restful.Request, response *restful.Response, params map[string][]string) | {
// ctxapi := ctx.(*context.APIContext)
hives := bees.GetFactories()
if len(hives) == 0 { // err != nil {
r.NotFound(request, response)
return
}
resp := HiveResponse{}
resp.Init(ctx)
for _, hive := range hives {
resp.AddHive(hive)
}
resp.Send(response)
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | api/resources/chains/chains_get.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/api/resources/chains/chains_get.go#L54-L69 | go | train | // GetByIDs sends out all items matching a set of IDs | func (r *ChainResource) GetByIDs(ctx smolder.APIContext, request *restful.Request, response *restful.Response, ids []string) | // GetByIDs sends out all items matching a set of IDs
func (r *ChainResource) GetByIDs(ctx smolder.APIContext, request *restful.Request, response *restful.Response, ids []string) | {
resp := ChainResponse{}
resp.Init(ctx)
for _, id := range ids {
chain := bees.GetChain(id)
if chain == nil {
r.NotFound(request, response)
return
}
resp.AddChain(*chain)
}
resp.Send(response)
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | api/resources/chains/chains_get.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/api/resources/chains/chains_get.go#L72-L83 | go | train | // Get sends out items matching the query parameters | func (r *ChainResource) Get(ctx smolder.APIContext, request *restful.Request, response *restful.Response, params map[string][]string) | // Get sends out items matching the query parameters
func (r *ChainResource) Get(ctx smolder.APIContext, request *restful.Request, response *restful.Response, params map[string][]string) | {
// ctxapi := ctx.(*context.APIContext)
chains := bees.GetChains()
resp := ChainResponse{}
resp.Init(ctx)
for _, chain := range chains {
resp.AddChain(chain)
}
resp.Send(response)
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/openweathermapbee/openweathermapbee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/openweathermapbee/openweathermapbee.go#L45-L66 | go | train | // Action triggers the action passed to it. | func (mod *OpenweathermapBee) Action(action bees.Action) []bees.Placeholder | // Action triggers the action passed to it.
func (mod *OpenweathermapBee) Action(action bees.Action) []bees.Placeholder | {
outs := []bees.Placeholder{}
switch action.Name {
case "get_current_weather":
var location string
action.Options.Bind("location", &location)
err := mod.current.CurrentByName(location)
if err != nil {
mod.LogErrorf("Failed to fetch weather: %v", err)
return nil
}
mod.TriggerCurrentWeatherEvent()
default:
panic("Unknown action triggered in " + mod.Name() + ": " + action.Name)
}
return outs
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/openweathermapbee/openweathermapbee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/openweathermapbee/openweathermapbee.go#L69-L83 | go | train | // Run executes the Bee's event loop. | func (mod *OpenweathermapBee) Run(eventChan chan bees.Event) | // Run executes the Bee's event loop.
func (mod *OpenweathermapBee) Run(eventChan chan bees.Event) | {
mod.evchan = eventChan
current, err := owm.NewCurrent(mod.unit, mod.language, mod.key)
if err != nil {
mod.LogErrorf("Failed to create new current service: %v", err)
return
}
mod.current = current
select {
case <-mod.SigChan:
return
}
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/openweathermapbee/openweathermapbee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/openweathermapbee/openweathermapbee.go#L86-L92 | go | train | // ReloadOptions parses the config options and initializes the Bee. | func (mod *OpenweathermapBee) ReloadOptions(options bees.BeeOptions) | // ReloadOptions parses the config options and initializes the Bee.
func (mod *OpenweathermapBee) ReloadOptions(options bees.BeeOptions) | {
mod.SetOptions(options)
options.Bind("unit", &mod.unit)
options.Bind("language", &mod.language)
options.Bind("key", &mod.key)
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/facebookbee/facebookbee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/facebookbee/facebookbee.go#L52-L72 | go | train | // Run executes the Bee's event loop. | func (mod *FacebookBee) Run(eventChan chan bees.Event) | // Run executes the Bee's event loop.
func (mod *FacebookBee) Run(eventChan chan bees.Event) | {
mod.evchan = eventChan
since := strconv.FormatInt(time.Now().UTC().Unix(), 10)
timeout := time.Duration(10 * time.Second)
for {
select {
case <-mod.SigChan:
return
case <-time.After(time.Duration(timeout)):
var err error
since, err = mod.handleStream(since)
if err != nil {
panic(err)
}
}
timeout = time.Minute
}
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/facebookbee/facebookbee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/facebookbee/facebookbee.go#L75-L103 | go | train | // Action triggers the action passed to it. | func (mod *FacebookBee) Action(action bees.Action) []bees.Placeholder | // Action triggers the action passed to it.
func (mod *FacebookBee) Action(action bees.Action) []bees.Placeholder | {
outs := []bees.Placeholder{}
switch action.Name {
case "post":
var text string
action.Options.Bind("text", &text)
mod.Logf("Attempting to post \"%s\" to Facebook", text)
params := facebook.Params{}
params["message"] = text
_, err := mod.session.Post("/me/feed", params)
if err != nil {
// err can be an facebook API error.
// if so, the Error struct contains error details.
if e, ok := err.(*facebook.Error); ok {
mod.LogErrorf("Error: [message:%v] [type:%v] [code:%v] [subcode:%v]",
e.Message, e.Type, e.Code, e.ErrorSubcode)
return outs
}
mod.LogErrorf(err.Error())
}
default:
panic("Unknown action triggered in " + mod.Name() + ": " + action.Name)
}
return outs
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/facebookbee/facebookbee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/facebookbee/facebookbee.go#L187-L193 | go | train | // ReloadOptions parses the config options and initializes the Bee. | func (mod *FacebookBee) ReloadOptions(options bees.BeeOptions) | // ReloadOptions parses the config options and initializes the Bee.
func (mod *FacebookBee) ReloadOptions(options bees.BeeOptions) | {
mod.SetOptions(options)
options.Bind("client_id", &mod.clientID)
options.Bind("client_secret", &mod.clientSecret)
options.Bind("access_token", &mod.accessToken)
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | app/app.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/app/app.go#L42-L46 | go | train | // AddFlags adds CliFlags to appflags | func AddFlags(flags []CliFlag) | // AddFlags adds CliFlags to appflags
func AddFlags(flags []CliFlag) | {
for _, flag := range flags {
appflags = append(appflags, flag)
}
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | app/app.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/app/app.go#L49-L60 | go | train | // Run sets up all the cli-param mappings | func Run() | // Run sets up all the cli-param mappings
func Run() | {
for _, f := range appflags {
switch f.Value.(type) {
case string:
flag.StringVar((f.V).(*string), f.Name, f.Value.(string), f.Desc)
case bool:
flag.BoolVar((f.V).(*bool), f.Name, f.Value.(bool), f.Desc)
}
}
flag.Parse()
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/twiliobee/twiliobeefactory.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/twiliobee/twiliobeefactory.go#L33-L40 | go | train | // New returns a new Bee instance configured with the supplied options. | func (factory *TwilioBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface | // New returns a new Bee instance configured with the supplied options.
func (factory *TwilioBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface | {
bee := TwilioBee{
Bee: bees.NewBee(name, factory.ID(), description, options),
}
bee.ReloadOptions(options)
return &bee
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/efabee/efabee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/efabee/efabee.go#L43-L205 | go | train | // Action triggers the action passed to it. | func (mod *EFABee) Action(action bees.Action) []bees.Placeholder | // Action triggers the action passed to it.
func (mod *EFABee) Action(action bees.Action) []bees.Placeholder | {
outs := []bees.Placeholder{}
switch action.Name {
case "directions":
var originParam, destParam string
action.Options.Bind("origin", &originParam)
action.Options.Bind("destination", &destParam)
origin, err := mod.efa.FindStop(originParam)
if err != nil {
mod.Logln("Origin does not exist or name is not unique!")
return outs
}
mod.Logf("Selected origin: %s (%d)", origin[0].Name, origin[0].ID)
destination, err := mod.efa.FindStop(destParam)
if err != nil {
mod.Logln("Destination does not exist or name is not unique!")
return outs
}
mod.Logf("Selected destination: %s (%d)", destination[0].Name, destination[0].ID)
routes, err := mod.efa.Route(origin[0].ID, destination[0].ID, time.Now())
for _, route := range routes {
mod.Logf("Trip duration: %s, %d transfers\n", route.ArrivalTime.Sub(route.DepartureTime), len(route.Trips)-1)
for _, trip := range route.Trips {
origin, err := mod.efa.Stop(trip.OriginID)
if err != nil {
mod.LogErrorf("%s", err)
return outs
}
dest, err := mod.efa.Stop(trip.DestinationID)
if err != nil {
mod.LogErrorf("%s", err)
return outs
}
ev := bees.Event{
Bee: mod.Name(),
Name: "trip",
Options: []bees.Placeholder{
{
Name: "mottype",
Type: "string",
Value: trip.MeansOfTransport.MotType.String(),
},
{
Name: "arrival_time",
Type: "string",
Value: trip.ArrivalTime.Format("15:04"),
},
{
Name: "departure_time",
Type: "string",
Value: trip.DepartureTime.Format("15:04"),
},
{
Name: "route",
Type: "string",
Value: trip.MeansOfTransport.Number,
},
{
Name: "origin",
Type: "string",
Value: origin.Name,
},
{
Name: "destination",
Type: "string",
Value: dest.Name,
},
{
Name: "origin_platform",
Type: "string",
Value: trip.OriginPlatform,
},
{
Name: "destination_platform",
Type: "string",
Value: trip.DestinationPlatform,
},
},
}
mod.eventChan <- ev
}
// only post one trip for now
break
}
case "departures":
stop := ""
amount := 3
action.Options.Bind("stop", &stop)
action.Options.Bind("amount", &amount)
//FIXME get departures
station, err := mod.efa.FindStop(stop)
if err != nil {
mod.Logln("Stop does not exist or name is not unique!")
return outs
}
mod.Logf("Selected stop: %s (%d)", station[0].Name, station[0].ID)
departures, err := station[0].Departures(time.Now(), amount)
if err != nil {
mod.Logln("Could not retrieve departure times!")
return outs
}
for _, departure := range departures {
destStop, err := mod.efa.Stop(departure.ServingLine.DestStopID)
if err != nil {
mod.Logln("Could not retrieve destination stop")
return outs
}
mod.Logf("Route %-5s due in %-2d minute%s --> %s",
departure.ServingLine.Number,
departure.CountDown,
"s",
destStop.Name)
ev := bees.Event{
Bee: mod.Name(),
Name: "departure",
Options: []bees.Placeholder{
{
Name: "mottype",
Type: "string",
Value: departure.ServingLine.MotType.String(),
},
{
Name: "eta",
Type: "int",
Value: departure.CountDown,
},
{
Name: "etatime",
Type: "string",
Value: departure.DateTime.Format("15:04"),
},
{
Name: "route",
Type: "string",
Value: departure.ServingLine.Number,
},
{
Name: "destination",
Type: "string",
Value: destStop.Name,
},
},
}
mod.eventChan <- ev
}
default:
panic("Unknown action triggered in " + mod.Name() + ": " + action.Name)
}
return outs
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/efabee/efabee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/efabee/efabee.go#L213-L218 | go | train | // ReloadOptions parses the config options and initializes the Bee. | func (mod *EFABee) ReloadOptions(options bees.BeeOptions) | // ReloadOptions parses the config options and initializes the Bee.
func (mod *EFABee) ReloadOptions(options bees.BeeOptions) | {
mod.SetOptions(options)
options.Bind("provider", &mod.Provider)
mod.efa = goefa.NewProvider(mod.Provider, true)
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/emailbee/emailbeefactory.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/emailbee/emailbeefactory.go#L33-L40 | go | train | // New returns a new Bee instance configured with the supplied options. | func (factory *EmailBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface | // New returns a new Bee instance configured with the supplied options.
func (factory *EmailBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface | {
bee := EmailBee{
Bee: bees.NewBee(name, factory.ID(), description, options),
}
bee.ReloadOptions(options)
return &bee
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/efabee/efabeefactory.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/efabee/efabeefactory.go#L33-L40 | go | train | // New returns a new Bee instance configured with the supplied options. | func (factory *EFABeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface | // New returns a new Bee instance configured with the supplied options.
func (factory *EFABeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface | {
bee := EFABee{
Bee: bees.NewBee(name, factory.ID(), description, options),
}
bee.ReloadOptions(options)
return &bee
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | beehive.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/beehive.go#L58-L70 | go | train | // Loads chains from config | func loadConfig() Config | // Loads chains from config
func loadConfig() Config | {
config := Config{}
j, err := ioutil.ReadFile(configFile)
if err == nil {
err = json.Unmarshal(j, &config)
if err != nil {
log.Fatal("Error parsing config file: ", err)
}
}
return config
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | beehive.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/beehive.go#L73-L82 | go | train | // Saves chains to config | func saveConfig(c Config) | // Saves chains to config
func saveConfig(c Config) | {
j, err := json.MarshalIndent(c, "", " ")
if err == nil {
err = ioutil.WriteFile(configFile, j, 0644)
}
if err != nil {
log.Fatal(err)
}
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/slackbee/slackbee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/slackbee/slackbee.go#L46-L79 | go | train | // Action triggers the action passed to it. | func (mod *SlackBee) Action(action bees.Action) []bees.Placeholder | // Action triggers the action passed to it.
func (mod *SlackBee) Action(action bees.Action) []bees.Placeholder | {
outs := []bees.Placeholder{}
switch action.Name {
case "send":
tos := []string{}
text := ""
action.Options.Bind("text", &text)
for _, opt := range action.Options {
if opt.Name == "channel" {
cid := mod.findChannelID(opt.Value.(string), false)
if cid != "" {
tos = append(tos, cid)
} else {
mod.Logf("Error: channel ID for %s not found", opt.Value.(string))
}
}
}
msgParams := slack.NewPostMessageParameters()
msgParams.LinkNames = 1
for _, to := range tos {
_, _, err := mod.client.PostMessage(to, slack.MsgOptionText(text, false), slack.MsgOptionPostMessageParameters(msgParams))
if err != nil {
mod.Logf("Error posting message to the slack channel %s: %s", to, err)
}
}
default:
panic("Unknown action triggered in " + mod.Name() + ": " + action.Name)
}
return outs
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/slackbee/slackbee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/slackbee/slackbee.go#L153-L197 | go | train | // Run executes the Bee's event loop. | func (mod *SlackBee) Run(eventChan chan bees.Event) | // Run executes the Bee's event loop.
func (mod *SlackBee) Run(eventChan chan bees.Event) | {
rtm := mod.client.NewRTM()
defer rtm.Disconnect()
go rtm.ManageConnection()
// Cache the channels
for k := range mod.channels {
mod.findChannelID(k, true)
}
for {
select {
case <-mod.SigChan:
return
case msg := <-rtm.IncomingEvents:
switch ev := msg.Data.(type) {
case *slack.MessageEvent:
if stringInMap(ev.Channel, mod.channels) {
u := ev.Msg.User
if u == "" {
u = ev.Msg.Username
}
t := ev.Msg.Text
if t == "" {
for _, v := range ev.Msg.Attachments {
sendEvent(mod.Name(), ev.Channel, u, v.Text, eventChan)
}
} else {
sendEvent(mod.Name(), ev.Channel, u, t, eventChan)
}
}
case *slack.RTMError:
mod.LogErrorf("Error: %s", ev.Error())
case *slack.InvalidAuthEvent:
mod.LogErrorf("Error: invalid credentials")
return
default:
// Ignore other events..
// fmt.Printf("Unexpected: %v\n", msg.Data)
}
}
}
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/slackbee/slackbee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/slackbee/slackbee.go#L200-L220 | go | train | // ReloadOptions parses the config options and initializes the Bee. | func (mod *SlackBee) ReloadOptions(options bees.BeeOptions) | // ReloadOptions parses the config options and initializes the Bee.
func (mod *SlackBee) ReloadOptions(options bees.BeeOptions) | {
mod.SetOptions(options)
apiKey := getAPIKey(&options)
client := slack.New(apiKey)
_, err := client.AuthTest()
if err != nil {
mod.LogErrorf("Error: authentication failed: %s", err)
return
}
mod.channels = map[string]string{}
if options.Value("channels") != nil {
for _, channel := range options.Value("channels").([]interface{}) {
mod.channels[channel.(string)] = ""
}
}
mod.apiKey = apiKey
mod.client = client
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/horizonboxbee/horizonboxbee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/horizonboxbee/horizonboxbee.go#L137-L148 | go | train | // Run executes the Bee's event loop. | func (mod *HorizonBoxBee) Run(cin chan bees.Event) | // Run executes the Bee's event loop.
func (mod *HorizonBoxBee) Run(cin chan bees.Event) | {
mod.eventChan = cin
for {
select {
case <-mod.SigChan:
return
case <-time.After(time.Duration(mod.interval) * time.Second):
mod.poll()
}
}
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/horizonboxbee/horizonboxbee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/horizonboxbee/horizonboxbee.go#L151-L158 | go | train | // ReloadOptions parses the config options and initializes the Bee. | func (mod *HorizonBoxBee) ReloadOptions(options bees.BeeOptions) | // ReloadOptions parses the config options and initializes the Bee.
func (mod *HorizonBoxBee) ReloadOptions(options bees.BeeOptions) | {
mod.SetOptions(options)
options.Bind("address", &mod.address)
options.Bind("user", &mod.user)
options.Bind("password", &mod.password)
options.Bind("interval", &mod.interval)
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/twitterbee/twitterbee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/twitterbee/twitterbee.go#L74-L115 | go | train | // Action triggers the action passed to it. | func (mod *TwitterBee) Action(action bees.Action) []bees.Placeholder | // Action triggers the action passed to it.
func (mod *TwitterBee) Action(action bees.Action) []bees.Placeholder | {
outs := []bees.Placeholder{}
switch action.Name {
case "tweet":
var status string
action.Options.Bind("status", &status)
mod.Logf("Attempting to post \"%s\" to Twitter", status)
_, err := mod.twitterAPI.PostTweet(status, url.Values{})
if err != nil {
mod.Logf("Error posting to Twitter %v", err)
mod.handleAnacondaError(err, "")
}
case "follow":
var username string
action.Options.Bind("username", &username)
mod.Logf("Attempting to follow \"%s\" to Twitter", username)
_, err := mod.twitterAPI.FollowUser(username)
if err != nil {
mod.Logf("Error following user on Twitter %v", err)
mod.handleAnacondaError(err, "")
}
case "unfollow":
var username string
action.Options.Bind("username", &username)
mod.Logf("Attempting to unfollow \"%s\" to Twitter", username)
_, err := mod.twitterAPI.UnfollowUser(username)
if err != nil {
mod.Logf("Error unfollowing user on Twitter %v", err)
mod.handleAnacondaError(err, "")
}
default:
panic("Unknown action triggered in " + mod.Name() + ": " + action.Name)
}
return outs
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/twitterbee/twitterbee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/twitterbee/twitterbee.go#L118-L140 | go | train | // Run executes the Bee's event loop. | func (mod *TwitterBee) Run(eventChan chan bees.Event) | // Run executes the Bee's event loop.
func (mod *TwitterBee) Run(eventChan chan bees.Event) | {
mod.evchan = eventChan
anaconda.SetConsumerKey(mod.consumerKey)
anaconda.SetConsumerSecret(mod.consumerSecret)
mod.twitterAPI = anaconda.NewTwitterApi(mod.accessToken, mod.accessTokenSecret)
mod.twitterAPI.ReturnRateLimitError(true)
defer mod.twitterAPI.Close()
// Test the credentials on startup
credentialsVerified := false
for !credentialsVerified {
ok, err := mod.twitterAPI.VerifyCredentials()
mod.handleAnacondaError(err, "Could not verify Twitter API Credentials")
credentialsVerified = ok
}
var err error
mod.self, err = mod.twitterAPI.GetSelf(url.Values{})
mod.handleAnacondaError(err, "Could not get own user object from Twitter API")
mod.handleStream()
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/twitterbee/twitterbee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/twitterbee/twitterbee.go#L300-L307 | go | train | // ReloadOptions parses the config options and initializes the Bee. | func (mod *TwitterBee) ReloadOptions(options bees.BeeOptions) | // ReloadOptions parses the config options and initializes the Bee.
func (mod *TwitterBee) ReloadOptions(options bees.BeeOptions) | {
mod.SetOptions(options)
options.Bind("consumer_key", &mod.consumerKey)
options.Bind("consumer_secret", &mod.consumerSecret)
options.Bind("access_token", &mod.accessToken)
options.Bind("access_token_secret", &mod.accessTokenSecret)
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | api/resources/bees/bees_post.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/api/resources/bees/bees_post.go#L56-L74 | go | train | // Post processes an incoming POST (create) request | func (r *BeeResource) Post(context smolder.APIContext, data interface{}, request *restful.Request, response *restful.Response) | // Post processes an incoming POST (create) request
func (r *BeeResource) Post(context smolder.APIContext, data interface{}, request *restful.Request, response *restful.Response) | {
resp := BeeResponse{}
resp.Init(context)
pps := data.(*BeePostStruct)
c, err := bees.NewBeeConfig(pps.Bee.Name, pps.Bee.Namespace, pps.Bee.Description, pps.Bee.Options)
if err != nil {
smolder.ErrorResponseHandler(request, response, err, smolder.NewErrorResponse(
422, // Go 1.7+: http.StatusUnprocessableEntity,
err,
"BeeResource POST"))
return
}
bee := bees.StartBee(c)
resp.AddBee(bee)
resp.Send(response)
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/simplepushbee/simplepushbee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/simplepushbee/simplepushbee.go#L39-L61 | go | train | // Action triggers the action passed to it. | func (mod *SimplepushBee) Action(action bees.Action) []bees.Placeholder | // Action triggers the action passed to it.
func (mod *SimplepushBee) Action(action bees.Action) []bees.Placeholder | {
outs := []bees.Placeholder{}
switch action.Name {
case "send":
sm := simplepush.Message{
SimplePushKey: mod.key,
Encrypt: mod.password != "",
Password: mod.password,
Salt: mod.salt,
}
action.Options.Bind("title", &sm.Title)
action.Options.Bind("message", &sm.Message)
action.Options.Bind("event", &sm.Event)
simplepush.Send(sm)
default:
panic("Unknown action triggered in " + mod.Name() + ": " + action.Name)
}
return outs
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/simplepushbee/simplepushbee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/simplepushbee/simplepushbee.go#L64-L70 | go | train | // ReloadOptions parses the config options and initializes the Bee. | func (mod *SimplepushBee) ReloadOptions(options bees.BeeOptions) | // ReloadOptions parses the config options and initializes the Bee.
func (mod *SimplepushBee) ReloadOptions(options bees.BeeOptions) | {
mod.SetOptions(options)
options.Bind("key", &mod.key)
options.Bind("password", &mod.password)
options.Bind("salt", &mod.salt)
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/serialbee/serialbeefactory.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/serialbee/serialbeefactory.go#L33-L40 | go | train | // New returns a new Bee instance configured with the supplied options. | func (factory *SerialBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface | // New returns a new Bee instance configured with the supplied options.
func (factory *SerialBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface | {
bee := SerialBee{
Bee: bees.NewBee(name, factory.ID(), description, options),
}
bee.ReloadOptions(options)
return &bee
} |
muesli/beehive | 4bfd4852e0b4bdcbc711323775cc7144ccd81b7e | bees/jenkinsbee/jenkinsbee.go | https://github.com/muesli/beehive/blob/4bfd4852e0b4bdcbc711323775cc7144ccd81b7e/bees/jenkinsbee/jenkinsbee.go#L193-L206 | go | train | // Action triggers the action passed to it. | func (mod *JenkinsBee) Action(action bees.Action) []bees.Placeholder | // Action triggers the action passed to it.
func (mod *JenkinsBee) Action(action bees.Action) []bees.Placeholder | {
outs := []bees.Placeholder{}
switch action.Name {
case "trigger":
jobname := ""
action.Options.Bind("job", &jobname)
mod.triggerBuild(jobname)
default:
panic("Unknown action triggered in " + mod.Name() + ": " + action.Name)
}
return outs
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | mock/mock.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/mock/mock.go#L94-L101 | go | train | // Return specifies the return arguments for the expectation.
//
// Mock.On("DoSomething").Return(errors.New("failed")) | func (c *Call) Return(returnArguments ...interface{}) *Call | // Return specifies the return arguments for the expectation.
//
// Mock.On("DoSomething").Return(errors.New("failed"))
func (c *Call) Return(returnArguments ...interface{}) *Call | {
c.lock()
defer c.unlock()
c.ReturnArguments = returnArguments
return c
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | mock/mock.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/mock/mock.go#L121-L126 | go | train | // Times indicates that that the mock should only return the indicated number
// of times.
//
// Mock.On("MyMethod", arg1, arg2).Return(returnArg1, returnArg2).Times(5) | func (c *Call) Times(i int) *Call | // Times indicates that that the mock should only return the indicated number
// of times.
//
// Mock.On("MyMethod", arg1, arg2).Return(returnArg1, returnArg2).Times(5)
func (c *Call) Times(i int) *Call | {
c.lock()
defer c.unlock()
c.Repeatability = i
return c
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | mock/mock.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/mock/mock.go#L132-L137 | go | train | // WaitUntil sets the channel that will block the mock's return until its closed
// or a message is received.
//
// Mock.On("MyMethod", arg1, arg2).WaitUntil(time.After(time.Second)) | func (c *Call) WaitUntil(w <-chan time.Time) *Call | // WaitUntil sets the channel that will block the mock's return until its closed
// or a message is received.
//
// Mock.On("MyMethod", arg1, arg2).WaitUntil(time.After(time.Second))
func (c *Call) WaitUntil(w <-chan time.Time) *Call | {
c.lock()
defer c.unlock()
c.WaitFor = w
return c
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | mock/mock.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/mock/mock.go#L142-L147 | go | train | // After sets how long to block until the call returns
//
// Mock.On("MyMethod", arg1, arg2).After(time.Second) | func (c *Call) After(d time.Duration) *Call | // After sets how long to block until the call returns
//
// Mock.On("MyMethod", arg1, arg2).After(time.Second)
func (c *Call) After(d time.Duration) *Call | {
c.lock()
defer c.unlock()
c.waitTime = d
return c
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | mock/mock.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/mock/mock.go#L157-L162 | go | train | // Run sets a handler to be called before returning. It can be used when
// mocking a method such as unmarshalers that takes a pointer to a struct and
// sets properties in such struct
//
// Mock.On("Unmarshal", AnythingOfType("*map[string]interface{}").Return().Run(func(args Arguments) {
// arg := args.Get(0).(*map[string]interface{})
// arg["foo"] = "bar"
// }) | func (c *Call) Run(fn func(args Arguments)) *Call | // Run sets a handler to be called before returning. It can be used when
// mocking a method such as unmarshalers that takes a pointer to a struct and
// sets properties in such struct
//
// Mock.On("Unmarshal", AnythingOfType("*map[string]interface{}").Return().Run(func(args Arguments) {
// arg := args.Get(0).(*map[string]interface{})
// arg["foo"] = "bar"
// })
func (c *Call) Run(fn func(args Arguments)) *Call | {
c.lock()
defer c.unlock()
c.RunFn = fn
return c
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | mock/mock.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/mock/mock.go#L166-L171 | go | train | // Maybe allows the method call to be optional. Not calling an optional method
// will not cause an error while asserting expectations | func (c *Call) Maybe() *Call | // Maybe allows the method call to be optional. Not calling an optional method
// will not cause an error while asserting expectations
func (c *Call) Maybe() *Call | {
c.lock()
defer c.unlock()
c.optional = true
return c
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | mock/mock.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/mock/mock.go#L180-L182 | go | train | // On chains a new expectation description onto the mocked interface. This
// allows syntax like.
//
// Mock.
// On("MyMethod", 1).Return(nil).
// On("MyOtherMethod", 'a', 'b', 'c').Return(errors.New("Some Error"))
//go:noinline | func (c *Call) On(methodName string, arguments ...interface{}) *Call | // On chains a new expectation description onto the mocked interface. This
// allows syntax like.
//
// Mock.
// On("MyMethod", 1).Return(nil).
// On("MyOtherMethod", 'a', 'b', 'c').Return(errors.New("Some Error"))
//go:noinline
func (c *Call) On(methodName string, arguments ...interface{}) *Call | {
return c.Parent.On(methodName, arguments...)
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | mock/mock.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/mock/mock.go#L231-L240 | go | train | // fail fails the current test with the given formatted format and args.
// In case that a test was defined, it uses the test APIs for failing a test,
// otherwise it uses panic. | func (m *Mock) fail(format string, args ...interface{}) | // fail fails the current test with the given formatted format and args.
// In case that a test was defined, it uses the test APIs for failing a test,
// otherwise it uses panic.
func (m *Mock) fail(format string, args ...interface{}) | {
m.mutex.Lock()
defer m.mutex.Unlock()
if m.test == nil {
panic(fmt.Sprintf(format, args...))
}
m.test.Errorf(format, args...)
m.test.FailNow()
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | mock/mock.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/mock/mock.go#L246-L258 | go | train | // On starts a description of an expectation of the specified method
// being called.
//
// Mock.On("MyMethod", arg1, arg2) | func (m *Mock) On(methodName string, arguments ...interface{}) *Call | // On starts a description of an expectation of the specified method
// being called.
//
// Mock.On("MyMethod", arg1, arg2)
func (m *Mock) On(methodName string, arguments ...interface{}) *Call | {
for _, arg := range arguments {
if v := reflect.ValueOf(arg); v.Kind() == reflect.Func {
panic(fmt.Sprintf("cannot use Func in expectations. Use mock.AnythingOfType(\"%T\")", arg))
}
}
m.mutex.Lock()
defer m.mutex.Unlock()
c := newCall(m, methodName, assert.CallerInfo(), arguments...)
m.ExpectedCalls = append(m.ExpectedCalls, c)
return c
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | mock/mock.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/mock/mock.go#L264-L276 | go | train | // /*
// Recording and responding to activity
// */ | func (m *Mock) findExpectedCall(method string, arguments ...interface{}) (int, *Call) | // /*
// Recording and responding to activity
// */
func (m *Mock) findExpectedCall(method string, arguments ...interface{}) (int, *Call) | {
for i, call := range m.ExpectedCalls {
if call.Method == method && call.Repeatability > -1 {
_, diffCount := call.Arguments.Diff(arguments)
if diffCount == 0 {
return i, call
}
}
}
return -1, nil
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | mock/mock.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/mock/mock.go#L317-L335 | go | train | // Called tells the mock object that a method has been called, and gets an array
// of arguments to return. Panics if the call is unexpected (i.e. not preceded by
// appropriate .On .Return() calls)
// If Call.WaitFor is set, blocks until the channel is closed or receives a message. | func (m *Mock) Called(arguments ...interface{}) Arguments | // Called tells the mock object that a method has been called, and gets an array
// of arguments to return. Panics if the call is unexpected (i.e. not preceded by
// appropriate .On .Return() calls)
// If Call.WaitFor is set, blocks until the channel is closed or receives a message.
func (m *Mock) Called(arguments ...interface{}) Arguments | {
// get the calling function's name
pc, _, _, ok := runtime.Caller(1)
if !ok {
panic("Couldn't get the caller information")
}
functionPath := runtime.FuncForPC(pc).Name()
//Next four lines are required to use GCCGO function naming conventions.
//For Ex: github_com_docker_libkv_store_mock.WatchTree.pN39_github_com_docker_libkv_store_mock.Mock
//uses interface information unlike golang github.com/docker/libkv/store/mock.(*Mock).WatchTree
//With GCCGO we need to remove interface information starting from pN<dd>.
re := regexp.MustCompile("\\.pN\\d+_")
if re.MatchString(functionPath) {
functionPath = re.Split(functionPath, -1)[0]
}
parts := strings.Split(functionPath, ".")
functionName := parts[len(parts)-1]
return m.MethodCalled(functionName, arguments...)
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | mock/mock.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/mock/mock.go#L341-L400 | go | train | // MethodCalled tells the mock object that the given method has been called, and gets
// an array of arguments to return. Panics if the call is unexpected (i.e. not preceded
// by appropriate .On .Return() calls)
// If Call.WaitFor is set, blocks until the channel is closed or receives a message. | func (m *Mock) MethodCalled(methodName string, arguments ...interface{}) Arguments | // MethodCalled tells the mock object that the given method has been called, and gets
// an array of arguments to return. Panics if the call is unexpected (i.e. not preceded
// by appropriate .On .Return() calls)
// If Call.WaitFor is set, blocks until the channel is closed or receives a message.
func (m *Mock) MethodCalled(methodName string, arguments ...interface{}) Arguments | {
m.mutex.Lock()
//TODO: could combine expected and closes in single loop
found, call := m.findExpectedCall(methodName, arguments...)
if found < 0 {
// we have to fail here - because we don't know what to do
// as the return arguments. This is because:
//
// a) this is a totally unexpected call to this method,
// b) the arguments are not what was expected, or
// c) the developer has forgotten to add an accompanying On...Return pair.
closestCall, mismatch := m.findClosestCall(methodName, arguments...)
m.mutex.Unlock()
if closestCall != nil {
m.fail("\n\nmock: Unexpected Method Call\n-----------------------------\n\n%s\n\nThe closest call I have is: \n\n%s\n\n%s\nDiff: %s",
callString(methodName, arguments, true),
callString(methodName, closestCall.Arguments, true),
diffArguments(closestCall.Arguments, arguments),
strings.TrimSpace(mismatch),
)
} else {
m.fail("\nassert: mock: I don't know what to return because the method call was unexpected.\n\tEither do Mock.On(\"%s\").Return(...) first, or remove the %s() call.\n\tThis method was unexpected:\n\t\t%s\n\tat: %s", methodName, methodName, callString(methodName, arguments, true), assert.CallerInfo())
}
}
if call.Repeatability == 1 {
call.Repeatability = -1
} else if call.Repeatability > 1 {
call.Repeatability--
}
call.totalCalls++
// add the call
m.Calls = append(m.Calls, *newCall(m, methodName, assert.CallerInfo(), arguments...))
m.mutex.Unlock()
// block if specified
if call.WaitFor != nil {
<-call.WaitFor
} else {
time.Sleep(call.waitTime)
}
m.mutex.Lock()
runFn := call.RunFn
m.mutex.Unlock()
if runFn != nil {
runFn(arguments)
}
m.mutex.Lock()
returnArgs := call.ReturnArguments
m.mutex.Unlock()
return returnArgs
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | mock/mock.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/mock/mock.go#L414-L430 | go | train | // AssertExpectationsForObjects asserts that everything specified with On and Return
// of the specified objects was in fact called as expected.
//
// Calls may have occurred in any order. | func AssertExpectationsForObjects(t TestingT, testObjects ...interface{}) bool | // AssertExpectationsForObjects asserts that everything specified with On and Return
// of the specified objects was in fact called as expected.
//
// Calls may have occurred in any order.
func AssertExpectationsForObjects(t TestingT, testObjects ...interface{}) bool | {
if h, ok := t.(tHelper); ok {
h.Helper()
}
for _, obj := range testObjects {
if m, ok := obj.(Mock); ok {
t.Logf("Deprecated mock.AssertExpectationsForObjects(myMock.Mock) use mock.AssertExpectationsForObjects(myMock)")
obj = &m
}
m := obj.(assertExpectationser)
if !m.AssertExpectations(t) {
t.Logf("Expectations didn't match for Mock: %+v", reflect.TypeOf(m))
return false
}
}
return true
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | mock/mock.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/mock/mock.go#L434-L466 | go | train | // AssertExpectations asserts that everything specified with On and Return was
// in fact called as expected. Calls may have occurred in any order. | func (m *Mock) AssertExpectations(t TestingT) bool | // AssertExpectations asserts that everything specified with On and Return was
// in fact called as expected. Calls may have occurred in any order.
func (m *Mock) AssertExpectations(t TestingT) bool | {
if h, ok := t.(tHelper); ok {
h.Helper()
}
m.mutex.Lock()
defer m.mutex.Unlock()
var somethingMissing bool
var failedExpectations int
// iterate through each expectation
expectedCalls := m.expectedCalls()
for _, expectedCall := range expectedCalls {
if !expectedCall.optional && !m.methodWasCalled(expectedCall.Method, expectedCall.Arguments) && expectedCall.totalCalls == 0 {
somethingMissing = true
failedExpectations++
t.Logf("FAIL:\t%s(%s)\n\t\tat: %s", expectedCall.Method, expectedCall.Arguments.String(), expectedCall.callerInfo)
} else {
if expectedCall.Repeatability > 0 {
somethingMissing = true
failedExpectations++
t.Logf("FAIL:\t%s(%s)\n\t\tat: %s", expectedCall.Method, expectedCall.Arguments.String(), expectedCall.callerInfo)
} else {
t.Logf("PASS:\t%s(%s)", expectedCall.Method, expectedCall.Arguments.String())
}
}
}
if somethingMissing {
t.Errorf("FAIL: %d out of %d expectation(s) were met.\n\tThe code you are testing needs to make %d more call(s).\n\tat: %s", len(expectedCalls)-failedExpectations, len(expectedCalls), failedExpectations, assert.CallerInfo())
}
return !somethingMissing
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | mock/mock.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/mock/mock.go#L469-L482 | go | train | // AssertNumberOfCalls asserts that the method was called expectedCalls times. | func (m *Mock) AssertNumberOfCalls(t TestingT, methodName string, expectedCalls int) bool | // AssertNumberOfCalls asserts that the method was called expectedCalls times.
func (m *Mock) AssertNumberOfCalls(t TestingT, methodName string, expectedCalls int) bool | {
if h, ok := t.(tHelper); ok {
h.Helper()
}
m.mutex.Lock()
defer m.mutex.Unlock()
var actualCalls int
for _, call := range m.calls() {
if call.Method == methodName {
actualCalls++
}
}
return assert.Equal(t, expectedCalls, actualCalls, fmt.Sprintf("Expected number of calls (%d) does not match the actual number of calls (%d).", expectedCalls, actualCalls))
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | mock/mock.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/mock/mock.go#L486-L505 | go | train | // AssertCalled asserts that the method was called.
// It can produce a false result when an argument is a pointer type and the underlying value changed after calling the mocked method. | func (m *Mock) AssertCalled(t TestingT, methodName string, arguments ...interface{}) bool | // AssertCalled asserts that the method was called.
// It can produce a false result when an argument is a pointer type and the underlying value changed after calling the mocked method.
func (m *Mock) AssertCalled(t TestingT, methodName string, arguments ...interface{}) bool | {
if h, ok := t.(tHelper); ok {
h.Helper()
}
m.mutex.Lock()
defer m.mutex.Unlock()
if !m.methodWasCalled(methodName, arguments) {
var calledWithArgs []string
for _, call := range m.calls() {
calledWithArgs = append(calledWithArgs, fmt.Sprintf("%v", call.Arguments))
}
if len(calledWithArgs) == 0 {
return assert.Fail(t, "Should have called with given arguments",
fmt.Sprintf("Expected %q to have been called with:\n%v\nbut no actual calls happened", methodName, arguments))
}
return assert.Fail(t, "Should have called with given arguments",
fmt.Sprintf("Expected %q to have been called with:\n%v\nbut actual calls were:\n %v", methodName, arguments, strings.Join(calledWithArgs, "\n")))
}
return true
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | mock/mock.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/mock/mock.go#L509-L520 | go | train | // AssertNotCalled asserts that the method was not called.
// It can produce a false result when an argument is a pointer type and the underlying value changed after calling the mocked method. | func (m *Mock) AssertNotCalled(t TestingT, methodName string, arguments ...interface{}) bool | // AssertNotCalled asserts that the method was not called.
// It can produce a false result when an argument is a pointer type and the underlying value changed after calling the mocked method.
func (m *Mock) AssertNotCalled(t TestingT, methodName string, arguments ...interface{}) bool | {
if h, ok := t.(tHelper); ok {
h.Helper()
}
m.mutex.Lock()
defer m.mutex.Unlock()
if m.methodWasCalled(methodName, arguments) {
return assert.Fail(t, "Should not have called with given arguments",
fmt.Sprintf("Expected %q to not have been called with:\n%v\nbut actually it was.", methodName, arguments))
}
return true
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | mock/mock.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/mock/mock.go#L621-L635 | go | train | // MatchedBy can be used to match a mock call based on only certain properties
// from a complex struct or some calculation. It takes a function that will be
// evaluated with the called argument and will return true when there's a match
// and false otherwise.
//
// Example:
// m.On("Do", MatchedBy(func(req *http.Request) bool { return req.Host == "example.com" }))
//
// |fn|, must be a function accepting a single argument (of the expected type)
// which returns a bool. If |fn| doesn't match the required signature,
// MatchedBy() panics. | func MatchedBy(fn interface{}) argumentMatcher | // MatchedBy can be used to match a mock call based on only certain properties
// from a complex struct or some calculation. It takes a function that will be
// evaluated with the called argument and will return true when there's a match
// and false otherwise.
//
// Example:
// m.On("Do", MatchedBy(func(req *http.Request) bool { return req.Host == "example.com" }))
//
// |fn|, must be a function accepting a single argument (of the expected type)
// which returns a bool. If |fn| doesn't match the required signature,
// MatchedBy() panics.
func MatchedBy(fn interface{}) argumentMatcher | {
fnType := reflect.TypeOf(fn)
if fnType.Kind() != reflect.Func {
panic(fmt.Sprintf("assert: arguments: %s is not a func", fn))
}
if fnType.NumIn() != 1 {
panic(fmt.Sprintf("assert: arguments: %s does not take exactly one argument", fn))
}
if fnType.NumOut() != 1 || fnType.Out(0).Kind() != reflect.Bool {
panic(fmt.Sprintf("assert: arguments: %s does not return a bool", fn))
}
return argumentMatcher{fn: reflect.ValueOf(fn)}
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | mock/mock.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/mock/mock.go#L638-L643 | go | train | // Get Returns the argument at the specified index. | func (args Arguments) Get(index int) interface{} | // Get Returns the argument at the specified index.
func (args Arguments) Get(index int) interface{} | {
if index+1 > len(args) {
panic(fmt.Sprintf("assert: arguments: Cannot call Get(%d) because there are %d argument(s).", index, len(args)))
}
return args[index]
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | mock/mock.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/mock/mock.go#L646-L653 | go | train | // Is gets whether the objects match the arguments specified. | func (args Arguments) Is(objects ...interface{}) bool | // Is gets whether the objects match the arguments specified.
func (args Arguments) Is(objects ...interface{}) bool | {
for i, obj := range args {
if obj != objects[i] {
return false
}
}
return true
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | mock/mock.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/mock/mock.go#L659-L728 | go | train | // Diff gets a string describing the differences between the arguments
// and the specified objects.
//
// Returns the diff string and number of differences found. | func (args Arguments) Diff(objects []interface{}) (string, int) | // Diff gets a string describing the differences between the arguments
// and the specified objects.
//
// Returns the diff string and number of differences found.
func (args Arguments) Diff(objects []interface{}) (string, int) | {
//TODO: could return string as error and nil for No difference
var output = "\n"
var differences int
var maxArgCount = len(args)
if len(objects) > maxArgCount {
maxArgCount = len(objects)
}
for i := 0; i < maxArgCount; i++ {
var actual, expected interface{}
var actualFmt, expectedFmt string
if len(objects) <= i {
actual = "(Missing)"
actualFmt = "(Missing)"
} else {
actual = objects[i]
actualFmt = fmt.Sprintf("(%[1]T=%[1]v)", actual)
}
if len(args) <= i {
expected = "(Missing)"
expectedFmt = "(Missing)"
} else {
expected = args[i]
expectedFmt = fmt.Sprintf("(%[1]T=%[1]v)", expected)
}
if matcher, ok := expected.(argumentMatcher); ok {
if matcher.Matches(actual) {
output = fmt.Sprintf("%s\t%d: PASS: %s matched by %s\n", output, i, actualFmt, matcher)
} else {
differences++
output = fmt.Sprintf("%s\t%d: FAIL: %s not matched by %s\n", output, i, actualFmt, matcher)
}
} else if reflect.TypeOf(expected) == reflect.TypeOf((*AnythingOfTypeArgument)(nil)).Elem() {
// type checking
if reflect.TypeOf(actual).Name() != string(expected.(AnythingOfTypeArgument)) && reflect.TypeOf(actual).String() != string(expected.(AnythingOfTypeArgument)) {
// not match
differences++
output = fmt.Sprintf("%s\t%d: FAIL: type %s != type %s - %s\n", output, i, expected, reflect.TypeOf(actual).Name(), actualFmt)
}
} else {
// normal checking
if assert.ObjectsAreEqual(expected, Anything) || assert.ObjectsAreEqual(actual, Anything) || assert.ObjectsAreEqual(actual, expected) {
// match
output = fmt.Sprintf("%s\t%d: PASS: %s == %s\n", output, i, actualFmt, expectedFmt)
} else {
// not match
differences++
output = fmt.Sprintf("%s\t%d: FAIL: %s != %s\n", output, i, actualFmt, expectedFmt)
}
}
}
if differences == 0 {
return "No differences.", differences
}
return output, differences
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | mock/mock.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/mock/mock.go#L732-L750 | go | train | // Assert compares the arguments with the specified objects and fails if
// they do not exactly match. | func (args Arguments) Assert(t TestingT, objects ...interface{}) bool | // Assert compares the arguments with the specified objects and fails if
// they do not exactly match.
func (args Arguments) Assert(t TestingT, objects ...interface{}) bool | {
if h, ok := t.(tHelper); ok {
h.Helper()
}
// get the differences
diff, diffCount := args.Diff(objects)
if diffCount == 0 {
return true
}
// there are differences... report them...
t.Logf(diff)
t.Errorf("%sArguments do not match.", assert.CallerInfo())
return false
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | mock/mock.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/mock/mock.go#L757-L779 | go | train | // String gets the argument at the specified index. Panics if there is no argument, or
// if the argument is of the wrong type.
//
// If no index is provided, String() returns a complete string representation
// of the arguments. | func (args Arguments) String(indexOrNil ...int) string | // String gets the argument at the specified index. Panics if there is no argument, or
// if the argument is of the wrong type.
//
// If no index is provided, String() returns a complete string representation
// of the arguments.
func (args Arguments) String(indexOrNil ...int) string | {
if len(indexOrNil) == 0 {
// normal String() method - return a string representation of the args
var argsStr []string
for _, arg := range args {
argsStr = append(argsStr, fmt.Sprintf("%s", reflect.TypeOf(arg)))
}
return strings.Join(argsStr, ",")
} else if len(indexOrNil) == 1 {
// Index has been specified - get the argument at that index
var index = indexOrNil[0]
var s string
var ok bool
if s, ok = args.Get(index).(string); !ok {
panic(fmt.Sprintf("assert: arguments: String(%d) failed because object wasn't correct type: %s", index, args.Get(index)))
}
return s
}
panic(fmt.Sprintf("assert: arguments: Wrong number of arguments passed to String. Must be 0 or 1, not %d", len(indexOrNil)))
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | mock/mock.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/mock/mock.go#L783-L790 | go | train | // Int gets the argument at the specified index. Panics if there is no argument, or
// if the argument is of the wrong type. | func (args Arguments) Int(index int) int | // Int gets the argument at the specified index. Panics if there is no argument, or
// if the argument is of the wrong type.
func (args Arguments) Int(index int) int | {
var s int
var ok bool
if s, ok = args.Get(index).(int); !ok {
panic(fmt.Sprintf("assert: arguments: Int(%d) failed because object wasn't correct type: %v", index, args.Get(index)))
}
return s
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | mock/mock.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/mock/mock.go#L794-L805 | go | train | // Error gets the argument at the specified index. Panics if there is no argument, or
// if the argument is of the wrong type. | func (args Arguments) Error(index int) error | // Error gets the argument at the specified index. Panics if there is no argument, or
// if the argument is of the wrong type.
func (args Arguments) Error(index int) error | {
obj := args.Get(index)
var s error
var ok bool
if obj == nil {
return nil
}
if s, ok = obj.(error); !ok {
panic(fmt.Sprintf("assert: arguments: Error(%d) failed because object wasn't correct type: %v", index, args.Get(index)))
}
return s
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | assert/assertion_order.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/assert/assertion_order.go#L202-L223 | go | train | // Greater asserts that the first element is greater than the second
//
// assert.Greater(t, 2, 1)
// assert.Greater(t, float64(2), float64(1))
// assert.Greater(t, "b", "a") | func Greater(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool | // Greater asserts that the first element is greater than the second
//
// assert.Greater(t, 2, 1)
// assert.Greater(t, float64(2), float64(1))
// assert.Greater(t, "b", "a")
func Greater(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool | {
if h, ok := t.(tHelper); ok {
h.Helper()
}
e1Kind := reflect.ValueOf(e1).Kind()
e2Kind := reflect.ValueOf(e2).Kind()
if e1Kind != e2Kind {
return Fail(t, "Elements should be the same type", msgAndArgs...)
}
res, isComparable := compare(e1, e2, e1Kind)
if !isComparable {
return Fail(t, fmt.Sprintf("Can not compare type \"%s\"", reflect.TypeOf(e1)), msgAndArgs...)
}
if res != -1 {
return Fail(t, fmt.Sprintf("\"%s\" is not greater than \"%s\"", e1, e2), msgAndArgs...)
}
return true
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | require/require_forward.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/require/require_forward.go#L24-L29 | go | train | // Conditionf uses a Comparison to assert a complex condition. | func (a *Assertions) Conditionf(comp assert.Comparison, msg string, args ...interface{}) | // Conditionf uses a Comparison to assert a complex condition.
func (a *Assertions) Conditionf(comp assert.Comparison, msg string, args ...interface{}) | {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
Conditionf(a.t, comp, msg, args...)
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | require/require_forward.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/require/require_forward.go#L37-L42 | go | train | // Contains asserts that the specified string, list(array, slice...) or map contains the
// specified substring or element.
//
// a.Contains("Hello World", "World")
// a.Contains(["Hello", "World"], "World")
// a.Contains({"Hello": "World"}, "Hello") | func (a *Assertions) Contains(s interface{}, contains interface{}, msgAndArgs ...interface{}) | // Contains asserts that the specified string, list(array, slice...) or map contains the
// specified substring or element.
//
// a.Contains("Hello World", "World")
// a.Contains(["Hello", "World"], "World")
// a.Contains({"Hello": "World"}, "Hello")
func (a *Assertions) Contains(s interface{}, contains interface{}, msgAndArgs ...interface{}) | {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
Contains(a.t, s, contains, msgAndArgs...)
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | require/require_forward.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/require/require_forward.go#L50-L55 | go | train | // Containsf asserts that the specified string, list(array, slice...) or map contains the
// specified substring or element.
//
// a.Containsf("Hello World", "World", "error message %s", "formatted")
// a.Containsf(["Hello", "World"], "World", "error message %s", "formatted")
// a.Containsf({"Hello": "World"}, "Hello", "error message %s", "formatted") | func (a *Assertions) Containsf(s interface{}, contains interface{}, msg string, args ...interface{}) | // Containsf asserts that the specified string, list(array, slice...) or map contains the
// specified substring or element.
//
// a.Containsf("Hello World", "World", "error message %s", "formatted")
// a.Containsf(["Hello", "World"], "World", "error message %s", "formatted")
// a.Containsf({"Hello": "World"}, "Hello", "error message %s", "formatted")
func (a *Assertions) Containsf(s interface{}, contains interface{}, msg string, args ...interface{}) | {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
Containsf(a.t, s, contains, msg, args...)
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | require/require_forward.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/require/require_forward.go#L78-L83 | go | train | // ElementsMatch asserts that the specified listA(array, slice...) is equal to specified
// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
// the number of appearances of each of them in both lists should match.
//
// a.ElementsMatch([1, 3, 2, 3], [1, 3, 3, 2]) | func (a *Assertions) ElementsMatch(listA interface{}, listB interface{}, msgAndArgs ...interface{}) | // ElementsMatch asserts that the specified listA(array, slice...) is equal to specified
// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
// the number of appearances of each of them in both lists should match.
//
// a.ElementsMatch([1, 3, 2, 3], [1, 3, 3, 2])
func (a *Assertions) ElementsMatch(listA interface{}, listB interface{}, msgAndArgs ...interface{}) | {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
ElementsMatch(a.t, listA, listB, msgAndArgs...)
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | require/require_forward.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/require/require_forward.go#L90-L95 | go | train | // ElementsMatchf asserts that the specified listA(array, slice...) is equal to specified
// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
// the number of appearances of each of them in both lists should match.
//
// a.ElementsMatchf([1, 3, 2, 3], [1, 3, 3, 2], "error message %s", "formatted") | func (a *Assertions) ElementsMatchf(listA interface{}, listB interface{}, msg string, args ...interface{}) | // ElementsMatchf asserts that the specified listA(array, slice...) is equal to specified
// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
// the number of appearances of each of them in both lists should match.
//
// a.ElementsMatchf([1, 3, 2, 3], [1, 3, 3, 2], "error message %s", "formatted")
func (a *Assertions) ElementsMatchf(listA interface{}, listB interface{}, msg string, args ...interface{}) | {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
ElementsMatchf(a.t, listA, listB, msg, args...)
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | require/require_forward.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/require/require_forward.go#L138-L143 | go | train | // EqualError asserts that a function returned an error (i.e. not `nil`)
// and that it is equal to the provided error.
//
// actualObj, err := SomeFunction()
// a.EqualError(err, expectedErrorString) | func (a *Assertions) EqualError(theError error, errString string, msgAndArgs ...interface{}) | // EqualError asserts that a function returned an error (i.e. not `nil`)
// and that it is equal to the provided error.
//
// actualObj, err := SomeFunction()
// a.EqualError(err, expectedErrorString)
func (a *Assertions) EqualError(theError error, errString string, msgAndArgs ...interface{}) | {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
EqualError(a.t, theError, errString, msgAndArgs...)
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | require/require_forward.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/require/require_forward.go#L150-L155 | go | train | // EqualErrorf asserts that a function returned an error (i.e. not `nil`)
// and that it is equal to the provided error.
//
// actualObj, err := SomeFunction()
// a.EqualErrorf(err, expectedErrorString, "error message %s", "formatted") | func (a *Assertions) EqualErrorf(theError error, errString string, msg string, args ...interface{}) | // EqualErrorf asserts that a function returned an error (i.e. not `nil`)
// and that it is equal to the provided error.
//
// actualObj, err := SomeFunction()
// a.EqualErrorf(err, expectedErrorString, "error message %s", "formatted")
func (a *Assertions) EqualErrorf(theError error, errString string, msg string, args ...interface{}) | {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
EqualErrorf(a.t, theError, errString, msg, args...)
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | require/require_forward.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/require/require_forward.go#L199-L204 | go | train | // Error asserts that a function returned an error (i.e. not `nil`).
//
// actualObj, err := SomeFunction()
// if a.Error(err) {
// assert.Equal(t, expectedError, err)
// } | func (a *Assertions) Error(err error, msgAndArgs ...interface{}) | // Error asserts that a function returned an error (i.e. not `nil`).
//
// actualObj, err := SomeFunction()
// if a.Error(err) {
// assert.Equal(t, expectedError, err)
// }
func (a *Assertions) Error(err error, msgAndArgs ...interface{}) | {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
Error(a.t, err, msgAndArgs...)
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | require/require_forward.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/require/require_forward.go#L212-L217 | go | train | // Errorf asserts that a function returned an error (i.e. not `nil`).
//
// actualObj, err := SomeFunction()
// if a.Errorf(err, "error message %s", "formatted") {
// assert.Equal(t, expectedErrorf, err)
// } | func (a *Assertions) Errorf(err error, msg string, args ...interface{}) | // Errorf asserts that a function returned an error (i.e. not `nil`).
//
// actualObj, err := SomeFunction()
// if a.Errorf(err, "error message %s", "formatted") {
// assert.Equal(t, expectedErrorf, err)
// }
func (a *Assertions) Errorf(err error, msg string, args ...interface{}) | {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
Errorf(a.t, err, msg, args...)
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | require/require_forward.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/require/require_forward.go#L248-L253 | go | train | // FailNow fails test | func (a *Assertions) FailNow(failureMessage string, msgAndArgs ...interface{}) | // FailNow fails test
func (a *Assertions) FailNow(failureMessage string, msgAndArgs ...interface{}) | {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
FailNow(a.t, failureMessage, msgAndArgs...)
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | require/require_forward.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/require/require_forward.go#L284-L289 | go | train | // Falsef asserts that the specified value is false.
//
// a.Falsef(myBool, "error message %s", "formatted") | func (a *Assertions) Falsef(value bool, msg string, args ...interface{}) | // Falsef asserts that the specified value is false.
//
// a.Falsef(myBool, "error message %s", "formatted")
func (a *Assertions) Falsef(value bool, msg string, args ...interface{}) | {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
Falsef(a.t, value, msg, args...)
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | require/require_forward.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/require/require_forward.go#L292-L297 | go | train | // FileExists checks whether a file exists in the given path. It also fails if the path points to a directory or there is an error when trying to check the file. | func (a *Assertions) FileExists(path string, msgAndArgs ...interface{}) | // FileExists checks whether a file exists in the given path. It also fails if the path points to a directory or there is an error when trying to check the file.
func (a *Assertions) FileExists(path string, msgAndArgs ...interface{}) | {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
FileExists(a.t, path, msgAndArgs...)
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | require/require_forward.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/require/require_forward.go#L300-L305 | go | train | // FileExistsf checks whether a file exists in the given path. It also fails if the path points to a directory or there is an error when trying to check the file. | func (a *Assertions) FileExistsf(path string, msg string, args ...interface{}) | // FileExistsf checks whether a file exists in the given path. It also fails if the path points to a directory or there is an error when trying to check the file.
func (a *Assertions) FileExistsf(path string, msg string, args ...interface{}) | {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
FileExistsf(a.t, path, msg, args...)
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | require/require_forward.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/require/require_forward.go#L312-L317 | go | train | // Greater asserts that the first element is greater than the second
//
// a.Greater(2, 1)
// a.Greater(float64(2), float64(1))
// a.Greater("b", "a") | func (a *Assertions) Greater(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) | // Greater asserts that the first element is greater than the second
//
// a.Greater(2, 1)
// a.Greater(float64(2), float64(1))
// a.Greater("b", "a")
func (a *Assertions) Greater(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) | {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
Greater(a.t, e1, e2, msgAndArgs...)
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | require/require_forward.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/require/require_forward.go#L536-L541 | go | train | // InDeltaSlicef is the same as InDelta, except it compares two slices. | func (a *Assertions) InDeltaSlicef(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) | // InDeltaSlicef is the same as InDelta, except it compares two slices.
func (a *Assertions) InDeltaSlicef(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) | {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
InDeltaSlicef(a.t, expected, actual, delta, msg, args...)
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | require/require_forward.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/require/require_forward.go#L570-L575 | go | train | // InEpsilonSlicef is the same as InEpsilon, except it compares each value from two slices. | func (a *Assertions) InEpsilonSlicef(expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) | // InEpsilonSlicef is the same as InEpsilon, except it compares each value from two slices.
func (a *Assertions) InEpsilonSlicef(expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) | {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
InEpsilonSlicef(a.t, expected, actual, epsilon, msg, args...)
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | require/require_forward.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/require/require_forward.go#L604-L609 | go | train | // JSONEq asserts that two JSON strings are equivalent.
//
// a.JSONEq(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`) | func (a *Assertions) JSONEq(expected string, actual string, msgAndArgs ...interface{}) | // JSONEq asserts that two JSON strings are equivalent.
//
// a.JSONEq(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)
func (a *Assertions) JSONEq(expected string, actual string, msgAndArgs ...interface{}) | {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
JSONEq(a.t, expected, actual, msgAndArgs...)
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | require/require_forward.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/require/require_forward.go#L636-L641 | go | train | // Lenf asserts that the specified object has specific length.
// Lenf also fails if the object has a type that len() not accept.
//
// a.Lenf(mySlice, 3, "error message %s", "formatted") | func (a *Assertions) Lenf(object interface{}, length int, msg string, args ...interface{}) | // Lenf asserts that the specified object has specific length.
// Lenf also fails if the object has a type that len() not accept.
//
// a.Lenf(mySlice, 3, "error message %s", "formatted")
func (a *Assertions) Lenf(object interface{}, length int, msg string, args ...interface{}) | {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
Lenf(a.t, object, length, msg, args...)
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | require/require_forward.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/require/require_forward.go#L830-L835 | go | train | // NotNilf asserts that the specified object is not nil.
//
// a.NotNilf(err, "error message %s", "formatted") | func (a *Assertions) NotNilf(object interface{}, msg string, args ...interface{}) | // NotNilf asserts that the specified object is not nil.
//
// a.NotNilf(err, "error message %s", "formatted")
func (a *Assertions) NotNilf(object interface{}, msg string, args ...interface{}) | {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
NotNilf(a.t, object, msg, args...)
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | require/require_forward.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/require/require_forward.go#L840-L845 | go | train | // NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic.
//
// a.NotPanics(func(){ RemainCalm() }) | func (a *Assertions) NotPanics(f assert.PanicTestFunc, msgAndArgs ...interface{}) | // NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic.
//
// a.NotPanics(func(){ RemainCalm() })
func (a *Assertions) NotPanics(f assert.PanicTestFunc, msgAndArgs ...interface{}) | {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
NotPanics(a.t, f, msgAndArgs...)
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | require/require_forward.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/require/require_forward.go#L883-L888 | go | train | // NotSubset asserts that the specified list(array, slice...) contains not all
// elements given in the specified subset(array, slice...).
//
// a.NotSubset([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]") | func (a *Assertions) NotSubset(list interface{}, subset interface{}, msgAndArgs ...interface{}) | // NotSubset asserts that the specified list(array, slice...) contains not all
// elements given in the specified subset(array, slice...).
//
// a.NotSubset([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]")
func (a *Assertions) NotSubset(list interface{}, subset interface{}, msgAndArgs ...interface{}) | {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
NotSubset(a.t, list, subset, msgAndArgs...)
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | require/require_forward.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/require/require_forward.go#L894-L899 | go | train | // NotSubsetf asserts that the specified list(array, slice...) contains not all
// elements given in the specified subset(array, slice...).
//
// a.NotSubsetf([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted") | func (a *Assertions) NotSubsetf(list interface{}, subset interface{}, msg string, args ...interface{}) | // NotSubsetf asserts that the specified list(array, slice...) contains not all
// elements given in the specified subset(array, slice...).
//
// a.NotSubsetf([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted")
func (a *Assertions) NotSubsetf(list interface{}, subset interface{}, msg string, args ...interface{}) | {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
NotSubsetf(a.t, list, subset, msg, args...)
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | require/require_forward.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/require/require_forward.go#L931-L936 | go | train | // PanicsWithValue asserts that the code inside the specified PanicTestFunc panics, and that
// the recovered panic value equals the expected panic value.
//
// a.PanicsWithValue("crazy error", func(){ GoCrazy() }) | func (a *Assertions) PanicsWithValue(expected interface{}, f assert.PanicTestFunc, msgAndArgs ...interface{}) | // PanicsWithValue asserts that the code inside the specified PanicTestFunc panics, and that
// the recovered panic value equals the expected panic value.
//
// a.PanicsWithValue("crazy error", func(){ GoCrazy() })
func (a *Assertions) PanicsWithValue(expected interface{}, f assert.PanicTestFunc, msgAndArgs ...interface{}) | {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
PanicsWithValue(a.t, expected, f, msgAndArgs...)
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | require/require_forward.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/require/require_forward.go#L974-L979 | go | train | // Regexpf asserts that a specified regexp matches a string.
//
// a.Regexpf(regexp.MustCompile("start", "error message %s", "formatted"), "it's starting")
// a.Regexpf("start...$", "it's not starting", "error message %s", "formatted") | func (a *Assertions) Regexpf(rx interface{}, str interface{}, msg string, args ...interface{}) | // Regexpf asserts that a specified regexp matches a string.
//
// a.Regexpf(regexp.MustCompile("start", "error message %s", "formatted"), "it's starting")
// a.Regexpf("start...$", "it's not starting", "error message %s", "formatted")
func (a *Assertions) Regexpf(rx interface{}, str interface{}, msg string, args ...interface{}) | {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
Regexpf(a.t, rx, str, msg, args...)
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | require/require_forward.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/require/require_forward.go#L1052-L1057 | go | train | // WithinDuration asserts that the two times are within duration delta of each other.
//
// a.WithinDuration(time.Now(), time.Now(), 10*time.Second) | func (a *Assertions) WithinDuration(expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) | // WithinDuration asserts that the two times are within duration delta of each other.
//
// a.WithinDuration(time.Now(), time.Now(), 10*time.Second)
func (a *Assertions) WithinDuration(expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) | {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
WithinDuration(a.t, expected, actual, delta, msgAndArgs...)
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | require/require_forward.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/require/require_forward.go#L1062-L1067 | go | train | // WithinDurationf asserts that the two times are within duration delta of each other.
//
// a.WithinDurationf(time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted") | func (a *Assertions) WithinDurationf(expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) | // WithinDurationf asserts that the two times are within duration delta of each other.
//
// a.WithinDurationf(time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted")
func (a *Assertions) WithinDurationf(expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) | {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
WithinDurationf(a.t, expected, actual, delta, msg, args...)
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | require/require_forward.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/require/require_forward.go#L1078-L1083 | go | train | // Zerof asserts that i is the zero value for its type. | func (a *Assertions) Zerof(i interface{}, msg string, args ...interface{}) | // Zerof asserts that i is the zero value for its type.
func (a *Assertions) Zerof(i interface{}, msg string, args ...interface{}) | {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
Zerof(a.t, i, msg, args...)
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | require/require.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/require/require.go#L16-L24 | go | train | // Condition uses a Comparison to assert a complex condition. | func Condition(t TestingT, comp assert.Comparison, msgAndArgs ...interface{}) | // Condition uses a Comparison to assert a complex condition.
func Condition(t TestingT, comp assert.Comparison, msgAndArgs ...interface{}) | {
if h, ok := t.(tHelper); ok {
h.Helper()
}
if assert.Condition(t, comp, msgAndArgs...) {
return
}
t.FailNow()
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | require/require.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/require/require.go#L27-L35 | go | train | // Conditionf uses a Comparison to assert a complex condition. | func Conditionf(t TestingT, comp assert.Comparison, msg string, args ...interface{}) | // Conditionf uses a Comparison to assert a complex condition.
func Conditionf(t TestingT, comp assert.Comparison, msg string, args ...interface{}) | {
if h, ok := t.(tHelper); ok {
h.Helper()
}
if assert.Conditionf(t, comp, msg, args...) {
return
}
t.FailNow()
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | require/require.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/require/require.go#L70-L78 | go | train | // DirExists checks whether a directory exists in the given path. It also fails if the path is a file rather a directory or there is an error checking whether it exists. | func DirExists(t TestingT, path string, msgAndArgs ...interface{}) | // DirExists checks whether a directory exists in the given path. It also fails if the path is a file rather a directory or there is an error checking whether it exists.
func DirExists(t TestingT, path string, msgAndArgs ...interface{}) | {
if h, ok := t.(tHelper); ok {
h.Helper()
}
if assert.DirExists(t, path, msgAndArgs...) {
return
}
t.FailNow()
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | require/require.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/require/require.go#L81-L89 | go | train | // DirExistsf checks whether a directory exists in the given path. It also fails if the path is a file rather a directory or there is an error checking whether it exists. | func DirExistsf(t TestingT, path string, msg string, args ...interface{}) | // DirExistsf checks whether a directory exists in the given path. It also fails if the path is a file rather a directory or there is an error checking whether it exists.
func DirExistsf(t TestingT, path string, msg string, args ...interface{}) | {
if h, ok := t.(tHelper); ok {
h.Helper()
}
if assert.DirExistsf(t, path, msg, args...) {
return
}
t.FailNow()
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | require/require.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/require/require.go#L96-L104 | go | train | // ElementsMatch asserts that the specified listA(array, slice...) is equal to specified
// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
// the number of appearances of each of them in both lists should match.
//
// assert.ElementsMatch(t, [1, 3, 2, 3], [1, 3, 3, 2]) | func ElementsMatch(t TestingT, listA interface{}, listB interface{}, msgAndArgs ...interface{}) | // ElementsMatch asserts that the specified listA(array, slice...) is equal to specified
// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
// the number of appearances of each of them in both lists should match.
//
// assert.ElementsMatch(t, [1, 3, 2, 3], [1, 3, 3, 2])
func ElementsMatch(t TestingT, listA interface{}, listB interface{}, msgAndArgs ...interface{}) | {
if h, ok := t.(tHelper); ok {
h.Helper()
}
if assert.ElementsMatch(t, listA, listB, msgAndArgs...) {
return
}
t.FailNow()
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | require/require.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/require/require.go#L111-L119 | go | train | // ElementsMatchf asserts that the specified listA(array, slice...) is equal to specified
// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
// the number of appearances of each of them in both lists should match.
//
// assert.ElementsMatchf(t, [1, 3, 2, 3], [1, 3, 3, 2], "error message %s", "formatted") | func ElementsMatchf(t TestingT, listA interface{}, listB interface{}, msg string, args ...interface{}) | // ElementsMatchf asserts that the specified listA(array, slice...) is equal to specified
// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
// the number of appearances of each of them in both lists should match.
//
// assert.ElementsMatchf(t, [1, 3, 2, 3], [1, 3, 3, 2], "error message %s", "formatted")
func ElementsMatchf(t TestingT, listA interface{}, listB interface{}, msg string, args ...interface{}) | {
if h, ok := t.(tHelper); ok {
h.Helper()
}
if assert.ElementsMatchf(t, listA, listB, msg, args...) {
return
}
t.FailNow()
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | require/require.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/require/require.go#L171-L179 | go | train | // EqualError asserts that a function returned an error (i.e. not `nil`)
// and that it is equal to the provided error.
//
// actualObj, err := SomeFunction()
// assert.EqualError(t, err, expectedErrorString) | func EqualError(t TestingT, theError error, errString string, msgAndArgs ...interface{}) | // EqualError asserts that a function returned an error (i.e. not `nil`)
// and that it is equal to the provided error.
//
// actualObj, err := SomeFunction()
// assert.EqualError(t, err, expectedErrorString)
func EqualError(t TestingT, theError error, errString string, msgAndArgs ...interface{}) | {
if h, ok := t.(tHelper); ok {
h.Helper()
}
if assert.EqualError(t, theError, errString, msgAndArgs...) {
return
}
t.FailNow()
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | require/require.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/require/require.go#L186-L194 | go | train | // EqualErrorf asserts that a function returned an error (i.e. not `nil`)
// and that it is equal to the provided error.
//
// actualObj, err := SomeFunction()
// assert.EqualErrorf(t, err, expectedErrorString, "error message %s", "formatted") | func EqualErrorf(t TestingT, theError error, errString string, msg string, args ...interface{}) | // EqualErrorf asserts that a function returned an error (i.e. not `nil`)
// and that it is equal to the provided error.
//
// actualObj, err := SomeFunction()
// assert.EqualErrorf(t, err, expectedErrorString, "error message %s", "formatted")
func EqualErrorf(t TestingT, theError error, errString string, msg string, args ...interface{}) | {
if h, ok := t.(tHelper); ok {
h.Helper()
}
if assert.EqualErrorf(t, theError, errString, msg, args...) {
return
}
t.FailNow()
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | require/require.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/require/require.go#L200-L208 | go | train | // EqualValues asserts that two objects are equal or convertable to the same types
// and equal.
//
// assert.EqualValues(t, uint32(123), int32(123)) | func EqualValues(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) | // EqualValues asserts that two objects are equal or convertable to the same types
// and equal.
//
// assert.EqualValues(t, uint32(123), int32(123))
func EqualValues(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) | {
if h, ok := t.(tHelper); ok {
h.Helper()
}
if assert.EqualValues(t, expected, actual, msgAndArgs...) {
return
}
t.FailNow()
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | require/require.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/require/require.go#L214-L222 | go | train | // EqualValuesf asserts that two objects are equal or convertable to the same types
// and equal.
//
// assert.EqualValuesf(t, uint32(123, "error message %s", "formatted"), int32(123)) | func EqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) | // EqualValuesf asserts that two objects are equal or convertable to the same types
// and equal.
//
// assert.EqualValuesf(t, uint32(123, "error message %s", "formatted"), int32(123))
func EqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) | {
if h, ok := t.(tHelper); ok {
h.Helper()
}
if assert.EqualValuesf(t, expected, actual, msg, args...) {
return
}
t.FailNow()
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | require/require.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/require/require.go#L247-L255 | go | train | // Error asserts that a function returned an error (i.e. not `nil`).
//
// actualObj, err := SomeFunction()
// if assert.Error(t, err) {
// assert.Equal(t, expectedError, err)
// } | func Error(t TestingT, err error, msgAndArgs ...interface{}) | // Error asserts that a function returned an error (i.e. not `nil`).
//
// actualObj, err := SomeFunction()
// if assert.Error(t, err) {
// assert.Equal(t, expectedError, err)
// }
func Error(t TestingT, err error, msgAndArgs ...interface{}) | {
if h, ok := t.(tHelper); ok {
h.Helper()
}
if assert.Error(t, err, msgAndArgs...) {
return
}
t.FailNow()
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | require/require.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/require/require.go#L263-L271 | go | train | // Errorf asserts that a function returned an error (i.e. not `nil`).
//
// actualObj, err := SomeFunction()
// if assert.Errorf(t, err, "error message %s", "formatted") {
// assert.Equal(t, expectedErrorf, err)
// } | func Errorf(t TestingT, err error, msg string, args ...interface{}) | // Errorf asserts that a function returned an error (i.e. not `nil`).
//
// actualObj, err := SomeFunction()
// if assert.Errorf(t, err, "error message %s", "formatted") {
// assert.Equal(t, expectedErrorf, err)
// }
func Errorf(t TestingT, err error, msg string, args ...interface{}) | {
if h, ok := t.(tHelper); ok {
h.Helper()
}
if assert.Errorf(t, err, msg, args...) {
return
}
t.FailNow()
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | require/require.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/require/require.go#L300-L308 | go | train | // Fail reports a failure through | func Fail(t TestingT, failureMessage string, msgAndArgs ...interface{}) | // Fail reports a failure through
func Fail(t TestingT, failureMessage string, msgAndArgs ...interface{}) | {
if h, ok := t.(tHelper); ok {
h.Helper()
}
if assert.Fail(t, failureMessage, msgAndArgs...) {
return
}
t.FailNow()
} |
stretchr/testify | 34c6fa2dc70986bccbbffcc6130f6920a924b075 | require/require.go | https://github.com/stretchr/testify/blob/34c6fa2dc70986bccbbffcc6130f6920a924b075/require/require.go#L322-L330 | go | train | // FailNowf fails test | func FailNowf(t TestingT, failureMessage string, msg string, args ...interface{}) | // FailNowf fails test
func FailNowf(t TestingT, failureMessage string, msg string, args ...interface{}) | {
if h, ok := t.(tHelper); ok {
h.Helper()
}
if assert.FailNowf(t, failureMessage, msg, args...) {
return
}
t.FailNow()
} |