Skip to content

Conversation

nevill
Copy link
Contributor

@nevill nevill commented Jun 23, 2020

This is still WIP. It intends to fix #133 at the end.
To create this draft PR because I want to get some early feedback from @slrtbtfs .

Copy link
Member

@slrtbtfs slrtbtfs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's great to see some progress on the testing side!

The approach in this PR looks generally sane to me, though it'd be nice to have more test cases.

There is also some non-trivial logic, that chooses what kind of completions should be provided. Those should at some point be tested as well, but that doesn't need to happen in the same PR.

)

// This is a mock object which serves as a test helper
type MockMetadataService struct {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this might be used in other tests as well, it should probably live in a separate file.

t.Errorf("Error occurred when calling completeMetricName: %s.\n", err)
}

if len(*items) != 1 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we would also check the content of the returned items.

return "testhost:9090"
}

func TestMetricNameCompletion(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func TestMetricNameCompletion(t *testing.T) {
func TestMetricNameCompletion(t *testing.T) {
// nolint: funlen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Integration test for getting metadata from Prometheus

2 participants