Debian Codegraph @

schema/internal/parser_checks_test.go

raw
1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3
4 package internal // import "go.opentelemetry.io/otel/schema/internal"
5
6 import (
7 "testing"
8
9 "github.com/stretchr/testify/assert"
10 )
11
12 func TestCheckFileFormatField(t *testing.T) {
13 // Invalid file format version numbers.
14 assert.Error(t, CheckFileFormatField("not a semver", 1, 0))
15 assert.Error(t, CheckFileFormatField("2.0.0", 1, 0))
16 assert.Error(t, CheckFileFormatField("1.1.0", 1, 0))
17 assert.Error(t, CheckFileFormatField("1.1.0", -1, 0))
18 assert.Error(t, CheckFileFormatField("1.1.0", 1, -2))
19
20 assert.Error(t, CheckFileFormatField("1.2.0", 1, 1))
21
22 // Valid cases.
23 assert.NoError(t, CheckFileFormatField("1.0.0", 1, 0))
24 assert.NoError(t, CheckFileFormatField("1.0.1", 1, 0))
25 assert.NoError(t, CheckFileFormatField("1.0.10000-alpha+4857", 1, 0))
26
27 assert.NoError(t, CheckFileFormatField("1.0.0", 1, 1))
28 assert.NoError(t, CheckFileFormatField("1.0.1", 1, 1))
29 assert.NoError(t, CheckFileFormatField("1.0.10000-alpha+4857", 1, 1))
30 assert.NoError(t, CheckFileFormatField("1.1.0", 1, 1))
31 assert.NoError(t, CheckFileFormatField("1.1.1", 1, 1))
32 }