Skip to content

Commit

Permalink
Adding missing tests, fixed readme, reset version, ruff formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
merschformann committed Aug 21, 2024
1 parent 985ca31 commit 7f97280
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .nextmv/golden/hello-world/inputs/input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "world"
}
5 changes: 5 additions & 0 deletions .nextmv/golden/hello-world/inputs/input.json.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"statistics": {
"message": "Hello, world"
}
}
28 changes: 28 additions & 0 deletions .nextmv/golden/hello-world/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package mip

import (
"os"
"testing"

"github.com/nextmv-io/sdk/golden"
)

func TestMain(m *testing.M) {
code := m.Run()
os.Exit(code)
}

func TestGolden(t *testing.T) {
golden.FileTests(
t,
"inputs",
golden.Config{
UseStdIn: true,
UseStdOut: true,
ExecutionConfig: &golden.ExecutionConfig{
Command: "python3",
Args: []string{"../../../hello-world/main.py"},
},
},
)
}
1 change: 1 addition & 0 deletions .nextmv/readme/hello-world/0.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pip3 install -r requirements.txt
Empty file.
1 change: 1 addition & 0 deletions .nextmv/readme/hello-world/1.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
echo '{"name":"world"}' | python3 main.py
1 change: 1 addition & 0 deletions .nextmv/readme/hello-world/1.sh.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"statistics": {"message": "Hello, world"}}
3 changes: 3 additions & 0 deletions .nextmv/readme/hello-world/2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cat input.json | docker run -i --rm \
-v $(pwd):/app ghcr.io/nextmv-io/runtime/python:3.11 \
sh -c 'pip install -r requirements.txt &> /dev/null && python3 /app/main.py'
6 changes: 6 additions & 0 deletions .nextmv/readme/workflow-configuration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ apps:
silent: true
- name: 2.sh
skip: true
- name: hello-world
scripts:
- name: 0.sh
silent: true
- name: 2.sh
skip: true
- name: nextroute
scripts:
- name: 0.sh
Expand Down
2 changes: 1 addition & 1 deletion hello-world/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Follow these steps to run locally.
1. Run the command below to check that everything works as expected:

```bash
python3 main.py -input input.json -output output.json -recipient nextmv
echo '{"name":"world"}' | python3 main.py
```

1. A file `output.json` should have been created a greeting message.
Expand Down
2 changes: 1 addition & 1 deletion hello-world/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.1.0
v1.0.0
2 changes: 2 additions & 0 deletions hello-world/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import sys


def main():
# Read input data
input_data = json.load(sys.stdin)
Expand All @@ -17,5 +18,6 @@ def main():
# Give output result
json.dump(output, fp=sys.stdout)


if __name__ == "__main__":
main()

0 comments on commit 7f97280

Please sign in to comment.