Questions tagged [gomega]
24 questions
4
votes
3 answers
Ginkgo tests not being found?
I do not understand why 'go' cannot find my Ginkgo test files
Here's how my structure looks:
events
├── button_not_shown_event.go
├── events_test
│ └── button_not_shown_event_test.go
And here how my button_not_shown_event_test.go look…

Viren
- 5,812
- 6
- 45
- 98
3
votes
1 answer
Ginkgo/Gomega Panic Test Fails
I'm writing a test to assert that a function panics on invalid input, but Ginkgo records the panic as a failure instead of a passing result as expected.
func ParseUnixTimeString(unixTimeString string) time.Time {
i, err :=…

frederix
- 1,662
- 5
- 18
- 29
2
votes
1 answer
Can Gomega support verification of multiple return values of different types where the last one is not `error`?
For instance:
If I have a wrapper for https://pkg.go.dev/sync#Map.Load:
with the same method signature:
func Load(key string) (value interface{}, ok bool)
in Can Gomega's Equal() handle multiple values ? similar question was asked and the response…

user892960
- 309
- 2
- 11
2
votes
1 answer
How to test for infinite loop/recursion with ginkgo/gomega?
I have a golang function which recursively steps through a json string and replaces custom references with the json document they are referencing. I just noticed that I forgot to handle cyclic references, whose occurrence will lead to endless…

DonGiovanni
- 891
- 1
- 7
- 15
2
votes
1 answer
Can I Iterate the tests for ginkgo
Is it possible to have a variable number of test cases. Let's say I have a BeforeSuite function which calculates the values in the array.
Then based on the length of the array, I want to run one test per array element.
var _ = Describe("Outer",…

nishantkj911
- 21
- 3
2
votes
2 answers
How to use gomega's ContainElements matcher with a custom equality matcher
In a test I have a list actual of elements with a struct similar to this:
type MyStruct struct {
Field1 string
Field2 int32
.
. // a long list of other fields
.
}
I want to assert that actual contains the elements of…

pablochacin
- 947
- 1
- 14
- 35
2
votes
2 answers
Can Gomega's Equal() handle multiple values ?
I am testing a function to send a mock request to a server using gomega and I want to verify that 1. the request has started 2. the request has completed. For this I am returning two booleans. They should both evaluate to true in the example below…

user2969402
- 1,221
- 3
- 16
- 26
1
vote
1 answer
Time complexity of algorithm (Big O, Omega)
I'm trying to understand time complexities better and I was hoping someone could help me figure out the time complexity in the worst case for the following algorithm (in pseudocode):
for i= 0 to n−1:
if A[i] < 0:
b= 1
while b <…

bennietgek
- 65
- 5
1
vote
1 answer
ginkgo cleanup on failure
I am writing my test specs in Ginkgo.
My tests have the following structure:
It("Setup X, Y, Z resources and check conditions" func() {
// setup resources.
// assert certain conditions using
//cleanup resources
})
My question is, how…

SeattleOrBayArea
- 2,808
- 6
- 26
- 38
1
vote
1 answer
Test whether a function was called
Given this struct and function:
type ExampleModule struct {
DB *database.Store
AnotherModule AnotherModuleInterface
}
func(m *ExampleModule) A (i int, id int[]) error{
err := m.AnotherModuke.SomeFunc(i, id)
}
How can…

Frieda
- 163
- 1
- 1
- 10
1
vote
1 answer
How to install ginkgo and gomega using gopkg?
I am trying to install ginkgo and gomega using the gopkg.
It is throwing the following error:
src/gopkg.in/onsi/ginkgo.v1/ginkgo_dsl.go:24:2: use of internal package not allowed
src/gopkg.in/onsi/ginkgo.v1/ginkgo_dsl.go:25:2: use of internal…

hemanik
- 965
- 3
- 14
- 33
1
vote
1 answer
Gomega ghttp returns 500 status code
I've written some tests in Go using Ginkgo/Gomega, but no matter what I do, ghttp returns a 500 status to my client with no content. Here is some sample code:
var _ = Describe("Client", func() {
var (
server *ghttp.Server
)
…

bbengfort
- 5,254
- 4
- 44
- 57
1
vote
0 answers
Provide Terminal Input to `gexec.Session`
I need to provide input to an exec.Command that is started by Gomega's gexec.Session.
The command I'm executing is currently complaining that "stty: stdin isn't a terminal". How can I provide input to the spawned process that looks like it comes…

DeejUK
- 12,891
- 19
- 89
- 169
0
votes
2 answers
Can Gomega equal with ginkgo print full strings?
Example error print of a unit test:
Expected
: "...up - Finish..."
to equal |
: "...up - Vault ..."
Is there a way to increase the print limit this is just not practical…

rufreakde
- 542
- 4
- 17
0
votes
0 answers
ghttp multiple ressponses for same method, path
I am unit-testing client code using ghttp (gomega) where I have N paths, path1, path2 to pathN. I use server.RouteToHandler().
I also have a requirement that 2nd time the same method and path is called, I need to have a different response.
I could…

M.P
- 61
- 5