aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/cli/internal/graph/graph_test.go
blob: 9323e1946544443117dac8b1ab5b139c2f291e80 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package graph

import (
	"testing"

	"gotest.tools/v3/assert"
)

func Test_CommandsInvokingTurbo(t *testing.T) {
	type testCase struct {
		command string
		match   bool
	}
	testCases := []testCase{
		{
			"turbo run foo",
			true,
		},
		{
			"rm -rf ~/Library/Caches/pnpm && turbo run foo && rm -rf ~/.npm",
			true,
		},
		{
			"FLAG=true turbo run foo",
			true,
		},
		{
			"npx turbo run foo",
			true,
		},
		{
			"echo starting; turbo foo; echo done",
			true,
		},
		// We don't catch this as if people are going to try to invoke the turbo
		// binary directly, they'll always be able to work around us.
		{
			"./node_modules/.bin/turbo foo",
			false,
		},
		{
			"rm -rf ~/Library/Caches/pnpm && rm -rf ~/Library/Caches/turbo && rm -rf ~/.npm && rm -rf ~/.pnpm-store && rm -rf ~/.turbo",
			false,
		},
	}

	for _, tc := range testCases {
		assert.Equal(t, commandLooksLikeTurbo(tc.command), tc.match, tc.command)
	}
}