Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: testutil package returning unexpected results #494

Closed
philipgough opened this issue Nov 9, 2018 · 0 comments
Closed

Bug: testutil package returning unexpected results #494

philipgough opened this issue Nov 9, 2018 · 0 comments
Assignees
Labels

Comments

@philipgough
Copy link
Contributor

I'm new to working with Prometheus so apologies if this is a misunderstanding on my part.

I noticed when writing a test for a Counter without any ConstLabels defined in the CounterOpts struct, the test will fail and provide an error message saying two identical strings do not match.

This can be replicated by modifying slightly one of the tests in the testutil_test.go file, by just removing the labels, example:

func TestCollectAndCompareBug(t *testing.T) {
	const metadata = `
		# HELP some_total A value that represents a counter.
		# TYPE some_total counter
	`

	c := prometheus.NewCounter(prometheus.CounterOpts{
		Name: "some_total",
		Help: "A value that represents a counter.",
	})
	c.Inc()

	expected := `

		some_total 1
	`

	if err := CollectAndCompare(c, strings.NewReader(metadata+expected), "some_total"); err != nil {
		t.Errorf("unexpected collecting result:\n%s", err)
	}
}

This results in the following output:

--- FAIL: TestCollectAndCompareBug (0.00s)
    testutil_test.go:165: unexpected collecting result:
        
        metric output does not match expectation; want:
        
        # HELP some_total A value that represents a counter.
        # TYPE some_total counter
        some_total 1
        
        
        got:
        
        # HELP some_total A value that represents a counter.
        # TYPE some_total counter
        some_total 1
        
FAIL

Process finished with exit code 1

I haven't dug in too deeply but if this is a bug and anyone have some pointers to fix I can take it on as soon as I have some free cycles.

@beorn7 beorn7 self-assigned this Nov 9, 2018
@philipgough philipgough changed the title Bug: testutil package returning unexpected results Bug: **testutil** package returning unexpected results Nov 9, 2018
@philipgough philipgough changed the title Bug: **testutil** package returning unexpected results Bug: testutil package returning unexpected results Nov 9, 2018
@beorn7 beorn7 added the bug label Nov 13, 2018
beorn7 pushed a commit that referenced this issue Nov 13, 2018
Signed-off-by: beorn7 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants