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

Proof that strings for enum are not backwards compatible #81

Closed
wants to merge 1 commit into from

Conversation

bogdandrutu
Copy link
Member

PR only to be used as example for opentelemetry-proto discussion

=== RUN   TestDecodeAggregationTemporality
=== RUN   TestDecodeAggregationTemporality/string
=== RUN   TestDecodeAggregationTemporality/unknown_string
    enum_test.go:45: no error expected, got: proto: (line 1:28): invalid value for enum type: "foo"
=== RUN   TestDecodeAggregationTemporality/int
=== RUN   TestDecodeAggregationTemporality/unknown_int
--- FAIL: TestDecodeAggregationTemporality (0.00s)
    --- PASS: TestDecodeAggregationTemporality/string (0.00s)
    --- FAIL: TestDecodeAggregationTemporality/unknown_string (0.00s)

    --- PASS: TestDecodeAggregationTemporality/int (0.00s)
    --- PASS: TestDecodeAggregationTemporality/unknown_int (0.00s)

FAIL

Signed-off-by: Bogdan Drutu [email protected]

```
=== RUN   TestDecodeAggregationTemporality
=== RUN   TestDecodeAggregationTemporality/string
=== RUN   TestDecodeAggregationTemporality/unknown_string
    enum_test.go:45: no error expected, got: proto: (line 1:28): invalid value for enum type: "foo"
=== RUN   TestDecodeAggregationTemporality/int
=== RUN   TestDecodeAggregationTemporality/unknown_int
--- FAIL: TestDecodeAggregationTemporality (0.00s)
    --- PASS: TestDecodeAggregationTemporality/string (0.00s)
    --- FAIL: TestDecodeAggregationTemporality/unknown_string (0.00s)

    --- PASS: TestDecodeAggregationTemporality/int (0.00s)
    --- PASS: TestDecodeAggregationTemporality/unknown_int (0.00s)

FAIL
```

Signed-off-by: Bogdan Drutu <[email protected]>
{
name: "string",
jsonStr: fmt.Sprintf("{\"aggregation_temporality\":\"%s\"}",
otlpmetrics.AggregationTemporality_AGGREGATION_TEMPORALITY_CUMULATIVE.String()),
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't you set the field to the enum value and Marshal() it?

@pellared
Copy link
Member

pellared commented Jun 6, 2023

@bogdandrutu Can we close this PR?

@pellared pellared closed this Jun 26, 2023
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.

3 participants