Skip to content

Commit c3c3096

Browse files
authored
chore: update script (#439)
1 parent c6b49f9 commit c3c3096

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed

.github/scripts/split_spec.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set -eou pipefail
33

44
echo "Running FOAS CLI versions command"
5-
foascli versions -s openapi-foas.json -o ./openapi/v2/versions.json --env "${target_env:?}" --stability-level stable
5+
foascli versions -s openapi-foas.json -o ./openapi/v2/versions.json --env "${target_env:?}" --stability-level stable --stability-level preview
66

77
echo "Running FOAS CLI split command with the following --env=${target_env:?} and -o=./openapi/v2/openapi.json"
88

@@ -12,5 +12,8 @@ mv -f "openapi-foas.json" "./openapi/v2.json"
1212
foascli split -s openapi-foas.yaml --env "${target_env:?}" -o ./openapi/v2/openapi.yaml
1313
mv -f "openapi-foas.yaml" "./openapi/v2.yaml"
1414

15+
# Create folder if it does not exist
16+
mkdir -p ./openapi/private
17+
1518
echo "Moving preview files to preview and private-preview folder"
1619
find ./openapi/v2 -type f -name "*private-preview*" -exec mv -f {} ./openapi/private/ \;
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package apiversion
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/assert"
7+
"github.com/stretchr/testify/require"
8+
)
9+
10+
func TestIsPreviewSabilityLevel(t *testing.T) {
11+
assert.True(t, IsPreviewSabilityLevel("preview"))
12+
assert.True(t, IsPreviewSabilityLevel("PREVIEW"))
13+
assert.True(t, IsPreviewSabilityLevel("prEvIEW"))
14+
assert.True(t, IsPreviewSabilityLevel("private-preview"))
15+
assert.True(t, IsPreviewSabilityLevel("public-preview"))
16+
assert.False(t, IsPreviewSabilityLevel("stable"))
17+
assert.False(t, IsPreviewSabilityLevel("invalid"))
18+
}
19+
20+
func TestIsPrivatePreviewSabilityLevel(t *testing.T) {
21+
assert.True(t, IsPrivatePreviewSabilityLevel("private-preview"))
22+
assert.False(t, IsPrivatePreviewSabilityLevel("public-preview"))
23+
assert.False(t, IsPrivatePreviewSabilityLevel("preview"))
24+
assert.False(t, IsPrivatePreviewSabilityLevel("stable"))
25+
assert.False(t, IsPrivatePreviewSabilityLevel("invalid"))
26+
}
27+
28+
func TestIsPublicPreviewSabilityLevel(t *testing.T) {
29+
assert.True(t, IsPublicPreviewSabilityLevel("public-preview"))
30+
assert.True(t, IsPublicPreviewSabilityLevel("preview"))
31+
assert.False(t, IsPublicPreviewSabilityLevel("private-preview"))
32+
assert.False(t, IsPublicPreviewSabilityLevel("stable"))
33+
assert.False(t, IsPublicPreviewSabilityLevel("invalid"))
34+
}
35+
36+
func TestIsStableSabilityLevel(t *testing.T) {
37+
assert.True(t, IsStableSabilityLevel("stable"))
38+
assert.False(t, IsStableSabilityLevel("preview"))
39+
assert.False(t, IsStableSabilityLevel("private-preview"))
40+
assert.False(t, IsStableSabilityLevel("public-preview"))
41+
assert.False(t, IsStableSabilityLevel("invalid"))
42+
}
43+
44+
func TestValidateStabilityLevel(t *testing.T) {
45+
require.NoError(t, ValidateStabilityLevel("stable"))
46+
require.NoError(t, ValidateStabilityLevel("preview"))
47+
require.NoError(t, ValidateStabilityLevel("private-preview"))
48+
require.NoError(t, ValidateStabilityLevel("public-preview"))
49+
assert.Error(t, ValidateStabilityLevel("invalid"))
50+
}

0 commit comments

Comments
 (0)