Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.

Unit test using input and output proto files #223

Merged
merged 7 commits into from
Sep 18, 2019

Conversation

rghetia
Copy link
Contributor

@rghetia rghetia commented Sep 17, 2019

No description provided.

@codecov-io
Copy link

codecov-io commented Sep 17, 2019

Codecov Report

Merging #223 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #223   +/-   ##
=======================================
  Coverage   73.02%   73.02%           
=======================================
  Files          15       15           
  Lines        1609     1609           
=======================================
  Hits         1175     1175           
  Misses        355      355           
  Partials       79       79

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4339afa...3826d9b. Read the comment docs.

// Read input Metrics proto.
f, err := ioutil.ReadFile("testdata/" + "inMetrics_" + filename + ".txt")
if err != nil {
panic("error opening in file " + filename)
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider t.Fatalf instead of panic. Same everywhere else.

Copy link
Contributor

@bogdandrutu bogdandrutu left a comment

Choose a reason for hiding this comment

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

Hope you will not get mad on me :), instead of having the "inMetrics" "outTS" as prefix can we have them as suffix?

inMetrics_ExportMetricsOfAllTypes.txt -> ExportMetricsOfAllTypes_InMetrics.txt

Theses way all the files related to one test will be in the close to each other. Another opinion may be to have:
testdata/export_metrics_of_all_types/[in.txt|out.txt|...]

Personally I prefer more the directory structure because then all files related to that test are in one directory.

@bogdandrutu
Copy link
Contributor

Also, this is super nice :)

double_value: 35.5
>
>
---
Copy link
Contributor

@songy23 songy23 Sep 17, 2019

Choose a reason for hiding this comment

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

Do you need these separators? I think you can use a metric list instead, something like

metric: <
  metric_descriptor: <...>
  timeseries: <...>
>
metric: <
  metric_descriptor: <...>
  timeseries: <...>
>
...

Then in test.go:

var metrics []*metricspb.metric
proto.UnmarshallTxt(metrics, file)

Copy link
Contributor

Choose a reason for hiding this comment

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

Same for metric descriptor requests and time series requests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

UnmarshalText only accepts Message

func UnmarshalText(s string, pb Message) error {

I would have to create wrapper proto like

message MetricList {
  repeated opencensus.proto.metric.v1.Metric metric = 1;
}

Let me know if I missed something.

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it - I didn't know that, LGTM then.

@rghetia
Copy link
Contributor Author

rghetia commented Sep 17, 2019

Hope you will not get mad on me :), instead of having the "inMetrics" "outTS" as prefix can we have them as suffix?

No problem.

Personally I prefer more the directory structure because then all files related to that test are in one directory.

I like the directory approach as well.

@rghetia
Copy link
Contributor Author

rghetia commented Sep 17, 2019

@bogdandrutu PTAL.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants