68 questions
1
vote
0
answers
24
views
Ginkgo Receive(BeEquivalentTo()) fails when comparing struct with interface payload
When writing Ginkgo unit tests, I ran into an issue asserting data received from a channel that contains a struct with an interface{} field.
Here's my models.go
type WsBaseMsg struct {
Type ...
0
votes
1
answer
236
views
Using multiple skips in Ginkgo test run
I am running tests using ginkgo, and I am trying to skip two of my tests that are not applicable to my environment.
./_output/bin/e2e.test --ginkgo.focus="sig-network.*[Conformance]" --...
1
vote
1
answer
162
views
Error on testing Gingko and Gomega for gingonic, w.Code not working
I have some tests written in Ginkgo that check the return-code, a 502 code should be returned at a specific moment in time, it returns 502 (as you can see on the logs) but the w.Code is still 200.
[...
0
votes
0
answers
219
views
Ginkgo - skip tests that don't match an expression
Trying to write a REGEX for the ginkgo --skip flag, that would skip tests that do NOT contain a string ("test1").
AFAIK golang doesn't support '!' (this post)
I know I can use --focus, but ...
1
vote
0
answers
173
views
How to get the current test configuration in ginkgo
Say I am runing a test suites, is there a way to get the information of the current test that's running, for example, its labels or its text?
my use case is as follows: I have a test suite which ...
0
votes
1
answer
163
views
Execution failing with go error for acceptance tests
I am trying to execute acceptance testing (AATs), But when eveni try to use ginkgo command or make aat, it fails with below go error :
lisha@admin-bld-box:$ ginkgo
Failed to compile topology-...
3
votes
1
answer
1k
views
How to output the test command Ginkgo uses
I have a Ginkgo test suite that has many test files.
I can run all tests under the test suite with the following command, where ./controller is the package that has all tests.
go test ./controllers/......
1
vote
1
answer
2k
views
How to write a unit test to mock clientset for a http call to return all nodes in a kubernetes cluster
I am currently working on getting familiar with Ginkgo testing framework to write unit tests for api calls and just plain functions. Having trouble wrapping my head around mocking things.
Right now I ...
2
votes
3
answers
2k
views
Can Gomega equal with ginkgo print full strings?
Example error print of a unit test:
Expected
<string>: "...up - Finish..."
to equal |
<string>: "...up - Vault .....
1
vote
0
answers
239
views
How to recover argument sent to mock with Ginkgo
I am working with /onsi/ginkgo/v2 v2.1.4 and /golang/mock v1.6.0 in Golang v1.19.2
And I want to retrieve the argument that was sent to the mock's InsertOneProspecto function.
ctrl = gomock....
2
votes
1
answer
1k
views
Using ginkgo with different go versions
I'm using go with multiple version as stated in this doc https://go.dev/doc/manage-install
go install golang.org/dl/go1.10.7@latest
go1.10.7 download
And I'm also using ginkgo, which I installed like ...
3
votes
1
answer
444
views
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 ...
1
vote
0
answers
119
views
Ginkgo binaries not seen in Mac directories
I have installed ginkgo, but I cannot locate it inside the /Users/user-name/gowork/src/github.com/onsi folder. If I delete the gowork folder, I can see the ginkgo folders within it, in Trash.
ginkgo ...
0
votes
1
answer
653
views
Reducing duplication in ginkgo specs/tests
I was writing tests using ginkgo framework, and wanted to reduce duplication within my tests. Suppose I have two tests, which have a exactly common middle section, but different start and end sections....
2
votes
0
answers
483
views
How to run before all suites in ginkgo?
I'm integrating mock server to out tests. As part of it I need to clear all the request that was caught by mock server. Due to restrictions of the service we use, I can do it only once for all the ...
4
votes
1
answer
3k
views
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) ...
1
vote
1
answer
4k
views
golang ginkgo test coverage across packages
I have the following file structure:
❯ tree
.
├── go.mod
├── go.sum
├── Makefile
├── p1
│ └── p1.go
└── tests
└── integration
└── integration_suite_test.go
3 directories, 5 files
Where,...
2
votes
2
answers
5k
views
Ginkgo: Mocking a method for unit test
Please note that struct S implements the interface I.
I'm trying to test MethodA by mocking the response from MethodB.
sample.go:
package service
// This is implemented by S
type I interface {
...
8
votes
1
answer
8k
views
Unable to run ginkgo bootstrap command on mac
When I run this command
ginkgo bootstrap
I am getting this error
zsh: command not found: ginkgo
I have already installed ginkgo using the following command
go get -u github.com/onsi/ginkgo/ginkgo
...
2
votes
1
answer
1k
views
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 ...
-1
votes
2
answers
709
views
Variable in It spec text always 0 although changed in BeforeEach in ginkgo/gomega
In my code snippet below or https://play.golang.org/p/tLld-zNF2zp, testValue was declared inside Describe block, changed in BeforeEach block. Then, used in.
It
Expect
The test passes as expected. ...
0
votes
1
answer
834
views
Ginkgo: how to combine test reports
I'm setting up GitLab CI.
We use Ginkgo tests for BDD.
Ginkgo creates a report per each folder where tests are located.
This create a problem with collecting all reports and publishing it as a single ...
2
votes
1
answer
2k
views
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 ...
9
votes
1
answer
12k
views
how to run a single spec using ginkgo test framework
./I have a test suite that has 4 specs, like this:
var _ = Describe("Start a Cycle", func() {
It("test 1", func() {...})
It("test 2", func() {...})
It("test 3&...
1
vote
1
answer
130
views
How to pass my Docker credential before/while running e2e tests on Kubernetes
I am trying to run e2e tests on Kubernetes cluster but while running Pods are pulled from docker and the docker is using default username present in the git-hub and the limit is exceeding.
I need to ...
0
votes
1
answer
420
views
How do you change the "Cap" value of an []map[string]interface{} in go lang?
I am trying to do some testing with ginkgo and gomega, I get down to the assertion error
Expected
<[]map[string]interface {} | len:1, cap:1>: []
To equal
<[]map[string]...
-2
votes
1
answer
1k
views
Test a map[string]interface{} with ginkgo and gomega
During testing I get the error message
Expected
<[]map[string]interface {} | len:0, cap:0>: []
to equal
<[]map[string]interface {} | len:0, cap:0>: nil
How Do i ...
17
votes
2
answers
7k
views
How can I debug Ginkgo tests in VS Code?
I'm evaluating ginkgo at the moment - I very much like the BDD style.
However I'm unable at the moment to get the VS Code debugger to work with the framework. The official VS-Code extension provides ...
0
votes
1
answer
2k
views
async testing with Gingko and Gomega
I have expanded the following code as per my requirement. https://github.com/radovskyb/watcher/blob/master/example/basics/main.go
Purpose of this code is to watch of certain events (CREATE, WRITE) and ...
4
votes
1
answer
1k
views
kubernetes Operator-sdk test with envTest
I am a newbie for operator-sdk. Now I am writing test for operator with envtest framework, so I had a fake control-plane for environments.
Inside controller reconcile loop, once I initialize a CR, ...
1
vote
1
answer
2k
views
How to run tests in a specific order with ginkgo?
I use ginkgo to write some tests, including:
books_suite_test.go
install_test.go
reading_test.go
isbn_test.go
uninstall_test.go
how to run these tests in a specific order as following:
install_test....
0
votes
1
answer
4k
views
Correct way to check for non null values in ginkgo test
Suppose a function Builder that returns a struct like this:
type MyStruct struct{
List []OtherStruct
}
I want to test the Builder function using ginkgo. I created a test suite with the ...
1
vote
0
answers
295
views
I have problem witch compilation android linux kernel
I have a problem with a compilation of Android Linux kernel
./include/trace/events/sched.h:269:2: error: #error "Unsupported NR_CPUS for lb tracepoint."
269 | #error "Unsupported ...
3
votes
3
answers
1k
views
when defer func is executed at ginkgo
I'm rewriting unit test of our k8s controller with ginkgo.
As previous TDD, for each test, we will have something like.
// Create the Channel object and expect the Reconcile
g.Expect(c....
0
votes
1
answer
435
views
Cannot start app server in BeforeSuit before running test on the endpoint
I wanna start my app in BeforeSuit and run a GET Request. Is that possible?
example_suite_test.go
func TestExample(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Example Suite")
}
...
0
votes
0
answers
124
views
Why reassign value from range loop in body of loop?
I stumbled upon something weird as I was writing tests. I have written a lot of table tests and I like the pattern recently I started working on a project that uses Ginkgo, and I wanted to write a ...
1
vote
0
answers
48
views
Things to be taken care Before Running Stellar Horizon Test Cases
I have cloned the Stellar Horizon Repo from GitHub written in Go.
I thought to run the test cases first.where the test cases have been written by using GINKGO Testing Framework. I have been running ...
5
votes
2
answers
1k
views
Disable Ginkgo warning of "slow test"
I am using Ginkgo to execute some relatively long-running integration tests. Interspersed with my test output is the occasional warning that my tests are taking too long to execute:
• [SLOW TEST:30....
0
votes
0
answers
190
views
Whether we can run ginkgo test cases using console input or test data in any file formats?
I need to pass user data via console or any file formats to ginkgo test methods. Let me know the ways.
I am looking into Table Driven Tests, but I am looking for test data which is located outside of ...
1
vote
0
answers
1k
views
Passing multiple test data to ginkgo test.go file
I have a test method like below:
It("test description", func() {
expectcc.ResponseOk(name.Invoke(`issue`, &cpaper.test{
Issuer: IssuerName,
PaperNumber: "0001",
...
1
vote
1
answer
1k
views
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 ...
1
vote
1
answer
425
views
False positive when sending SIGTERM to Ginkgo test suite
While writing tests using Ginkgo framework I noticed, that pressing C-c to terminate a running suite generates false positive.
note the green "1 Passed"
When you look at the code you will notice ...
0
votes
0
answers
889
views
How to match private struct types using Ginkgo and Gomega?
Assume that I have a function called GetQueue with GoLang and depends on the configuration, it would return different types of queue implementations.
func GetQueue(config string) *service.Queue {
...
1
vote
1
answer
1k
views
Ginkgo to cobertura and JUnit
I am using Shippable as my CI and my project is based on Go 1.11. All the unit tests are written in BDD style using Ginkgo and Gomega. In my test pipeline, I have something like:
gocov test ./... | ...
0
votes
1
answer
3k
views
Ginkgo skipped specs counted as failed
I've being using Ginkgo for a while and I have found a behavior I don't really understand. I have a set of specs that I only want to run if and only if a condition is available. If the condition is ...
2
votes
2
answers
2k
views
Ginkgo package testing
I'm implementing test suite for brand new go app and decided to use ginkgo. The app has main function and several packages
.
|- main.go
|- types
| |-- user.go
| |-- post.go
|- server_pkg
| |-- ...
1
vote
2
answers
712
views
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/...
2
votes
2
answers
6k
views
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 ...
0
votes
1
answer
1k
views
How to write test case in multiple test file using ginkgo?
How to write test case in multiple test file using ginkgo?
a_suite_test.go file:
func TestA(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "A Suite")
}
a_test.go:
var _ = Describe("A"...
2
votes
2
answers
3k
views
How to send custom signal to kill running process with Goland?
When I run/debug Ginkgo test from Intellij Idea (with Go plugin installed), it does not shut down gracefully if I press "Stop" button.
JustBeforeEach and AfterEach functions do not get executed and ...