Skip to content

Commit 03c03a6

Browse files
committed
add generate-model-tests script
1 parent b220c4a commit 03c03a6

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

generate-model-tests.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
# Generates new test files for models. Run from the root.
4+
5+
# allow generator to write test files
6+
sed -i.bak 's/^src\/Bandwidth\.Standard\.Test\//# src\/Bandwidth.Standard.Test\//' .openapi-generator-ignore && rm .openapi-generator-ignore.bak
7+
# remove current test files for models
8+
rm -f ./src/Bandwidth.Standard.Test/Unit/Model/*
9+
# generate new test files for models
10+
openapi-generator-cli generate -i bandwidth.yml -o ./ -c openapi-config.yml -g csharp > /dev/null
11+
# move generated test files to the correct location
12+
mv ./src/Bandwidth.Standard.Test/Model/* ./src/Bandwidth.Standard.Test/Unit/Model/
13+
# fix namespace declarations in moved test files
14+
sed -i '' 's/namespace Bandwidth\.Standard\.Test\.Model/namespace Bandwidth.Standard.Test.Unit.Model/g' ./src/Bandwidth.Standard.Test/Unit/Model/*.cs
15+
# remove the rest of the generated files
16+
rm -rf ./src/Bandwidth.Standard.Test/Api ./src/Bandwidth.Standard.Test/Model
17+
# discard changes to modified files only (leaves deletions and new test files intact)
18+
modified=$(git diff --name-only --diff-filter=M) && [ -n "$modified" ] && echo "$modified" | xargs git checkout --

0 commit comments

Comments
 (0)