MCPcopy Index your code
hub / github.com/rclone/rclone / TestEnvironmentVariables

Function TestEnvironmentVariables

cmdtest/environment_test.go:19–387  ·  view source on GitHub ↗

TestEnvironmentVariables demonstrates and verifies the test functions for end-to-end testing of rclone

(t *testing.T)

Source from the content-addressed store, hash-verified

17
18// TestEnvironmentVariables demonstrates and verifies the test functions for end-to-end testing of rclone
19func TestEnvironmentVariables(t *testing.T) {
20
21 createTestEnvironment(t)
22
23 testdataPath := createSimpleTestData(t)
24
25 // Non backend flags
26 // =================
27
28 // First verify default behaviour of the implicit max_depth=-1
29 env := ""
30 out, err := rcloneEnv(env, "lsl", testFolder)
31 //t.Logf("\n" + out)
32 if assert.NoError(t, err) {
33 assert.Contains(t, out, "rclone.config") // depth 1
34 assert.Contains(t, out, "file1.txt") // depth 2
35 assert.Contains(t, out, "fileA1.txt") // depth 3
36 assert.Contains(t, out, "fileAA1.txt") // depth 4
37 }
38
39 // Test of flag.Value
40 env = "RCLONE_MAX_DEPTH=2"
41 out, err = rcloneEnv(env, "lsl", testFolder)
42 if assert.NoError(t, err) {
43 assert.Contains(t, out, "file1.txt") // depth 2
44 assert.NotContains(t, out, "fileA1.txt") // depth 3
45 }
46
47 // Test of flag.Changed (tests #5341 Issue1)
48 env = "RCLONE_LOG_LEVEL=DEBUG"
49 out, err = rcloneEnv(env, "version", "--quiet")
50 if assert.Error(t, err) {
51 assert.Contains(t, out, " DEBUG ")
52 assert.Contains(t, out, "Can't set -q and --log-level")
53 assert.Contains(t, "exit status 1", err.Error())
54 }
55
56 // Test of flag.DefValue
57 env = "RCLONE_STATS=173ms"
58 out, err = rcloneEnv(env, "help", "flags")
59 if assert.NoError(t, err) {
60 assert.Contains(t, out, "(default 173ms)")
61 }
62
63 // Test of command line flags overriding environment flags
64 env = "RCLONE_MAX_DEPTH=2"
65 out, err = rcloneEnv(env, "lsl", testFolder, "--max-depth", "3")
66 if assert.NoError(t, err) {
67 assert.Contains(t, out, "fileA1.txt") // depth 3
68 assert.NotContains(t, out, "fileAA1.txt") // depth 4
69 }
70
71 // Test of debug logging while initialising flags from environment (tests #5341 Enhance1)
72 env = "RCLONE_STATS=173ms"
73 out, err = rcloneEnv(env, "version", "-vv")
74 if assert.NoError(t, err) {
75 assert.Contains(t, out, " DEBUG : ")
76 assert.Contains(t, out, "--stats")

Callers

nothing calls this directly

Calls 8

createTestEnvironmentFunction · 0.85
createSimpleTestDataFunction · 0.85
rcloneEnvFunction · 0.85
rcloneFunction · 0.85
ContainsMethod · 0.80
ErrorMethod · 0.65
SymlinkMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…