Skip to content

Commit b1b228a

Browse files
Migrated TestInventoryCreation from test_main.py to main_test.go
1 parent 095b590 commit b1b228a

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

Diff for: internal/integrationtest/main/main_test.go

+24
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package main_test
1717

1818
import (
1919
"encoding/json"
20+
"strings"
2021
"testing"
2122

2223
"github.com/arduino/arduino-cli/internal/integrationtest"
@@ -83,3 +84,26 @@ func TestVersion(t *testing.T) {
8384
// Checks if Commit's value is not empty
8485
require.NotEmpty(t, jsonMap["Commit"])
8586
}
87+
88+
func TestInventoryCreation(t *testing.T) {
89+
// Using version as a test command
90+
91+
env := testsuite.NewEnvironment(t)
92+
defer env.CleanUp()
93+
94+
cli := integrationtest.NewArduinoCliWithinEnvironment(env, &integrationtest.ArduinoCLIConfig{
95+
ArduinoCLIPath: paths.New("..", "..", "..", "arduino-cli"),
96+
UseSharedStagingFolder: true,
97+
})
98+
99+
// no logs
100+
stdout, _, _ := cli.Run("version")
101+
line := strings.TrimSpace(string(stdout))
102+
outLines := strings.Split(line, "\n")
103+
require.Len(t, outLines, 1)
104+
105+
// parse inventory file
106+
inventoryFile := cli.DataDir().Join("inventory.yaml")
107+
stream, _ := inventoryFile.ReadFile()
108+
require.True(t, strings.Contains(string(stream), "installation"))
109+
}

Diff for: test/test_main.py

-16
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,3 @@ def test_log_options(run_command, data_dir):
5050
with open(log_file) as f:
5151
for line in f.readlines():
5252
json.loads(line)
53-
54-
55-
def test_inventory_creation(run_command, data_dir):
56-
"""
57-
using `version` as a test command
58-
"""
59-
60-
# no logs
61-
out_lines = run_command(["version"]).stdout.strip().split("\n")
62-
assert len(out_lines) == 1
63-
64-
# parse inventory file
65-
inventory_file = os.path.join(data_dir, "inventory.yaml")
66-
with open(inventory_file, "r") as stream:
67-
inventory = yaml.safe_load(stream)
68-
assert "installation" in inventory

0 commit comments

Comments
 (0)