Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

medium tests for snap-collector-mock1 #946

Merged
merged 1 commit into from
Jun 29, 2016

Conversation

katarzyna-z
Copy link
Contributor

@katarzyna-z katarzyna-z commented May 24, 2016

Summary of changes:

  • Added medium tests for snap-collector-mock1

@intelsdi-x/snap-maintainers

@katarzyna-z katarzyna-z force-pushed the small_tests branch 2 times, most recently from e228c01 to 0cf6446 Compare May 24, 2016 09:00
@mbbroberg
Copy link
Contributor

FYI - this will conflict with #944 and can be resolved pending the order of merges @intelsdi-x/snap-maintainers

@mbbroberg
Copy link
Contributor

Hey @katarzyna-z - this looks great. Code overage is hitting the mark:

$ go test -tags=small -coverprofile=/tmp/coverage.out . && go tool cover -func=/tmp/coverage.out | grep -v '\t0.0%$'
ok      github.com/intelsdi-x/snap/plugin/collector/snap-collector-mock1    0.013s  coverage: 100.0% of statements
github.com/intelsdi-x/snap/plugin/collector/snap-collector-mock1/main.go:31:    main        100.0%
total:                                      (statements)    100.0%
$ cd mock/
$ go test -tags=small -coverprofile=/tmp/coverage.out . && go tool cover -func=/tmp/coverage.out | grep -v '\t0.0%$'
ok      github.com/intelsdi-x/snap/plugin/collector/snap-collector-mock1/mock   0.015s  coverage: 100.0% of statements
github.com/intelsdi-x/snap/plugin/collector/snap-collector-mock1/mock/mock.go:50:   CollectMetrics  100.0%
github.com/intelsdi-x/snap/plugin/collector/snap-collector-mock1/mock/mock.go:82:   GetMetricTypes  100.0%
github.com/intelsdi-x/snap/plugin/collector/snap-collector-mock1/mock/mock.go:99:   GetConfigPolicy 100.0%
github.com/intelsdi-x/snap/plugin/collector/snap-collector-mock1/mock/mock.go:111:  Meta        100.0%
github.com/intelsdi-x/snap/plugin/collector/snap-collector-mock1/mock/mock.go:125:  randInt     100.0%
total:                                          (statements)    100.0%

The only catch for our definition of small is that tests cover other packages. Like those in TestGetMetricTypes, also cover methods in node and core. I believe the goal of small tests would be to use nothing from other packages while you test a given method. Did I get that right @tjmcs?

"github.com/intelsdi-x/snap/control/plugin"
"github.com/intelsdi-x/snap/core"
"github.com/intelsdi-x/snap/core/cdata"
"github.com/intelsdi-x/snap/core/ctypes"
Copy link
Contributor

@tjmcs tjmcs May 24, 2016

Choose a reason for hiding this comment

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

The fact that these other Snap packages are being imported hints at this not being a true small test (since it relies on functionality from these other packages); ideally the calls to the functions or methods in these other packages should be mocked if this really is a set of small tests.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't agree with this approach. What is the point of mocking github.com/intelsdi-x/snap/core/ctypes, when I just need ctypes.ConfigValue for my test?

@geauxvirtual
Copy link
Contributor

geauxvirtual commented May 25, 2016

Disregard, forgot this is a plugin in snap repo.

@katarzyna-z katarzyna-z force-pushed the small_tests branch 3 times, most recently from 5e9f734 to aed8f03 Compare June 16, 2016 09:07
@katarzyna-z katarzyna-z changed the title small tests for snap-collector-mock1 medium tests for snap-collector-mock1 Jun 16, 2016
@katarzyna-z
Copy link
Contributor Author

I renamed the tests to "medium".

@intelsdi-x/snap-maintainers

@tjmcs
Copy link
Contributor

tjmcs commented Jun 23, 2016

LGTM, @katarzyna-z

@katarzyna-z
Copy link
Contributor Author

@intelsdi-x/snap-maintainers Can this pull request be merged?

@pittma
Copy link
Contributor

pittma commented Jun 29, 2016

LGTM too. Merging.

@pittma pittma merged commit 320ec8d into intelsdi-x:master Jun 29, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants