-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathrulesTest.m
More file actions
66 lines (53 loc) · 1.83 KB
/
Copy pathrulesTest.m
File metadata and controls
66 lines (53 loc) · 1.83 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
% Copyright 2019-2019 The MathWorks, Inc.
function tests = rulesTest()
% Rules Test tests expected behavoir of .env config
% See https://github.com/motdotla/dotenv#rules
tests = functiontests(localfunctions);
end
function testTopComment(testCase)
% Tests that lines starting with # are skipped
% specifically tests first line comment
d = dotenv('../config/topcomment.env');
testCase.verifyNumElements(fieldnames(d.env), 3);
end
function testMiddleComment(testCase)
% Tests that lines starting with # are skipped
% specifically tests interior comment
d = dotenv('../config/middlecomment.env');
testCase.verifyNumElements(fieldnames(d.env), 3);
end
function testBottomComment(testCase)
% Tests that lines starting with # are skipped
% specifically tests last line comment
d = dotenv('../config/bottomcomment.env');
testCase.verifyNumElements(fieldnames(d.env), 3);
end
function testBlankLines(testCase)
d = dotenv('../config/blanklines.env');
testCase.verifyNumElements(fieldnames(d.env), 4);
end
function testEqualsInPassword(testCase)
d = dotenv('../config/equalPassword.env');
testCase.verifyEqual("s1mpl3=123", d.env.DB_PASS);
end
function testWhitespaceValue(testCase)
d = dotenv('../config/whitespace.env');
testCase.verifyEqual("localhost server", d.env.DB_HOST);
end
function testEmptyValue(testCase)
d = dotenv('../config/empty.env');
testCase.verifyEqual(d.env.DB_HOST,"");
end
function testUnquotedWhitespace(testCase)
% D.configure should trim leading and trailing whitespace for whitespace values
d = dotenv('../config/whitespace.env');
testCase.verifyEqual(d.env.DB_USER, "george");
end
function testQuotedValues(testCase)
d = dotenv('../config/whitespace.env');
testCase.verifyEqual(d.env.DB_PASS, """ mypass """);
end
function testSingleValue(testCase)
d = dotenv('../config/single.env');
testCase.verifyEqual(d.env.DB_HOST, "localhost");
end