Skip to content

Commit 2527c9d

Browse files
committed
go e2e wip
1 parent bced93f commit 2527c9d

51 files changed

Lines changed: 2897 additions & 69 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package main_test
2+
3+
import (
4+
"testing"
5+
6+
"github.com/typisttech/php-matrix/internal"
7+
)
8+
9+
//go:generate go run ./main.go
10+
func Test(t *testing.T) {
11+
internal.RunTestscript(t)
12+
}

internal/composer/fail/testdata/bad_source.txtar renamed to internal/composer/bad-input/testdata/bad_mode.txtar

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
# DO NOT EDIT THIS FILE
2-
# This file is generated by "internal/composer/fail/main.go"
3-
# Test the "bad source" case
4-
5-
! exec php-matrix composer --source=bad
1+
! exec php-matrix composer --mode=bad
62
! stdout .
73
cmp stderr stderr.golden
84

95
-- stderr.golden --
106

11-
12-
[ERROR] Invalid --source "bad". Available sources: [auto, php.net, offline]
13-
7+
8+
[ERROR] Invalid --mode "bad". Available modes: [full, minor-only]
9+
1410

1511
composer [--source SOURCE] [--mode MODE] [--] [<path>]
1612

internal/composer/fail/testdata/bad_path.txtar renamed to internal/composer/bad-input/testdata/bad_path.txtar

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
# DO NOT EDIT THIS FILE
2-
# This file is generated by "internal/composer/fail/main.go"
3-
# Test the "bad path" case
4-
5-
! exec php-matrix composer composer2.json
1+
! exec php-matrix composer composer2.json
62
! stdout .
73
cmp stderr stderr.golden
84

internal/composer/fail/testdata/bad_mode.txtar renamed to internal/composer/bad-input/testdata/bad_source.txtar

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
# DO NOT EDIT THIS FILE
2-
# This file is generated by "internal/composer/fail/main.go"
3-
# Test the "bad mode" case
4-
5-
! exec php-matrix composer --source=bad
1+
! exec php-matrix composer --source=bad
62
! stdout .
73
cmp stderr stderr.golden
84

internal/composer/fail/main.go

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const fileTemplateRaw = `# DO NOT EDIT THIS FILE
1111
# This file is generated by "internal/composer/fail/main.go"
1212
# Test the "{{ .Name }}" case
1313
14-
! exec php-matrix composer {{ .Path }} {{ .Source }} {{ .Mode }}
14+
! exec php-matrix composer
1515
! stdout .
1616
cmp stderr stderr.golden
1717
@@ -22,45 +22,40 @@ cmp stderr stderr.golden
2222
`
2323

2424
const (
25-
GoodComposerJSON = `{"require":{"php":"^7.4"}}`
25+
goodComposerJSON = `{"require":{"php":"^7.4"}}`
2626
)
2727

2828
var cases = []data{
29-
{"bad source", "", "--source=bad", "", GoodComposerJSON},
30-
{"bad mode", "", "", "--source=bad", GoodComposerJSON},
31-
32-
{"bad path", "composer2.json", "", "", GoodComposerJSON},
33-
34-
{`no "require.php" is set/1`, "", "", "", `{{"require":{"some/package":"^1.0"}}`},
35-
{`no "require.php" is set/2`, "", "", "", `{"require":{}}`},
36-
{`no "require.php" is set/3`, "", "", "", `{"require":123}`},
37-
{`no "require.php" is set/4`, "", "", "", `{"require-dev":{"php":"^1.0"}}`},
38-
{`no "require.php" is set/5`, "", "", "", `{"php":"^1.0"}`},
39-
{`no "require.php" is set/6`, "", "", "", `{}`},
40-
41-
{`"require.php" is not a string/1`, "", "", "", `{"require":{"php":null}}`},
42-
{`"require.php" is not a string/2`, "", "", "", `{"require":{"php":{}}}`},
43-
{`"require.php" is not a string/3`, "", "", "", `{"require":{"php":[]}}`},
44-
{`"require.php" is not a string/4`, "", "", "", `{"require":{"php":123}}`},
45-
{`"require.php" is not a string/5`, "", "", "", `{"require":{"php":12.3}}`},
46-
{`"require.php" is not a string/6`, "", "", "", `{"require":{"php":true}}`},
47-
{`"require.php" is not a string/7`, "", "", "", `{"require":{"php":false}}`},
48-
49-
{`"require.php" is not a valid constraint/1`, "", "", "", `{"require":{"php":"invalid constraint"}}`},
50-
{`"require.php" is not a valid constraint/2`, "", "", "", `{"require":{"php":"~>1.0"}}`},
51-
{`"require.php" is not a valid constraint/3`, "", "", "", `{"require":{"php":""}}`},
52-
53-
{`unsatisfiable/1`, "", "", "", `{"require":{"php":">8.0 <7.0"}}`},
54-
{`unsatisfiable/2`, "", "", "", `{"require":{"php":">999"}}`},
29+
{`no "require.php" is set/1`, `{"require":{"some/package":"^1.0"}}`},
30+
{`no "require.php" is set/2`, `{"require":{}}`},
31+
{`no "require.php" is set/3`, `{"require":123}`},
32+
{`no "require.php" is set/4`, `{"require-dev":{"php":"^1.0"}}`},
33+
{`no "require.php" is set/5`, `{"php":"^1.0"}`},
34+
{`no "require.php" is set/6`, `{}`},
35+
36+
{`"require.php" is not a string/1`, `{"require":{"php":null}}`},
37+
{`"require.php" is not a string/2`, `{"require":{"php":{}}}`},
38+
{`"require.php" is not a string/3`, `{"require":{"php":[]}}`},
39+
{`"require.php" is not a string/4`, `{"require":{"php":123}}`},
40+
{`"require.php" is not a string/5`, `{"require":{"php":12.3}}`},
41+
{`"require.php" is not a string/6`, `{"require":{"php":true}}`},
42+
{`"require.php" is not a string/7`, `{"require":{"php":false}}`},
43+
44+
{`"require.php" is not a valid constraint/1`, `{"require":{"php":"invalid constraint"}}`},
45+
{`"require.php" is not a valid constraint/2`, `{"require":{"php":"~>1.0"}}`},
46+
{`"require.php" is not a valid constraint/3`, `{"require":{"php":""}}`},
47+
48+
{`unsatisfiable/1`, `{"require":{"php":">8.0 <7.0"}}`},
49+
{`unsatisfiable/2`, `{"require":{"php":">999"}}`},
50+
{`unsatisfiable/3`, `{"require":{"php":"dev-master"}}`},
51+
52+
{`invalid json`, `{invalid json`},
5553
}
5654

5755
var fileTemplate = template.Must(template.New("").Parse(fileTemplateRaw))
5856

5957
type data struct {
6058
name string
61-
Path string
62-
Source string
63-
Mode string
6459
ComposerJSON string
6560
}
6661

internal/composer/fail/testdata/_require.php__is_not_a_string_1.txtar

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# This file is generated by "internal/composer/fail/main.go"
33
# Test the ""require.php" is not a string/1" case
44

5-
! exec php-matrix composer
5+
! exec php-matrix composer
66
! stdout .
77
cmp stderr stderr.golden
88

internal/composer/fail/testdata/_require.php__is_not_a_string_2.txtar

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# This file is generated by "internal/composer/fail/main.go"
33
# Test the ""require.php" is not a string/2" case
44

5-
! exec php-matrix composer
5+
! exec php-matrix composer
66
! stdout .
77
cmp stderr stderr.golden
88

internal/composer/fail/testdata/_require.php__is_not_a_string_3.txtar

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# This file is generated by "internal/composer/fail/main.go"
33
# Test the ""require.php" is not a string/3" case
44

5-
! exec php-matrix composer
5+
! exec php-matrix composer
66
! stdout .
77
cmp stderr stderr.golden
88

internal/composer/fail/testdata/_require.php__is_not_a_string_4.txtar

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# This file is generated by "internal/composer/fail/main.go"
33
# Test the ""require.php" is not a string/4" case
44

5-
! exec php-matrix composer
5+
! exec php-matrix composer
66
! stdout .
77
cmp stderr stderr.golden
88

internal/composer/fail/testdata/_require.php__is_not_a_string_5.txtar

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# This file is generated by "internal/composer/fail/main.go"
33
# Test the ""require.php" is not a string/5" case
44

5-
! exec php-matrix composer
5+
! exec php-matrix composer
66
! stdout .
77
cmp stderr stderr.golden
88

0 commit comments

Comments
 (0)