Skip to content

Commit

Permalink
Merge pull request #1 from acampbel/master
Browse files Browse the repository at this point in the history
CI configs & test improvements
  • Loading branch information
gehrhorn authored Jul 23, 2020
2 parents b338c65 + 9307fde commit 9127262
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 19 deletions.
15 changes: 15 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: 2.1
orbs:
matlab: mathworks/[email protected]

jobs:
build:
machine:
image: ubuntu-1604:201903-01
steps:
- checkout
- matlab/install
- matlab/run-tests:
test-results-junit: test-results/matlab/results.xml
- store_test_results:
path: test-results
20 changes: 20 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
trigger:
- master

pool:
vmImage: 'ubuntu-latest'

steps:
- task: InstallMATLAB@0
- task: RunMATLABTests@0
inputs:
testResultsJUnit: test-results/results.xml
codeCoverageCobertura: code-coverage/coverage.xml
- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testResultsFiles: test-results/results.xml
- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: code-coverage/coverage.xml
2 changes: 2 additions & 0 deletions resources/project/Root.type.Files/.circleci.type.File.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version='1.0' encoding='UTF-8'?>
<Info />
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version='1.0' encoding='UTF-8'?>
<Info />
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version='1.0' encoding='UTF-8'?>
<Info />
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version='1.0' encoding='UTF-8'?>
<Info />
11 changes: 4 additions & 7 deletions tests/fileTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,18 @@
end

function testFileNotFound(testCase)
try
d = dotenv('config/dotenv'); % dosen't exist
catch ME
assert(string(ME.identifier) == 'DOTENV:CannotOpenFile');
end
testCase.verifyError(@() dotenv('config/dotenv'), 'DOTENV:CannotOpenFile', ...
'Should error properly for file that doesn''t exist');
end

function testDefaultLocation(testCase)
%% Opens default ./.env file
d = dotenv();
assert(d.env.DB_HOST == "localhost");
testCase.verifyEqual(d.env.DB_HOST, "localhost");
end

function testNamedLocation(testCase)
%% Opens nested .env file
d = dotenv('../config/.env');
assert(d.env.DB_HOST == "localhost");
testCase.verifyEqual(d.env.DB_HOST, "localhost");
end
20 changes: 10 additions & 10 deletions tests/rulesTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,57 +10,57 @@ function testTopComment(testCase)
% Tests that lines starting with # are skipped
% specifically tests first line comment
d = dotenv('../config/topcomment.env');
assert(numel(fieldnames(d.env)) == 3);
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');
assert(numel(fieldnames(d.env)) == 3);
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');
assert(numel(fieldnames(d.env)) == 3);
testCase.verifyNumElements(fieldnames(d.env), 3);
end

function testBlankLines(testCase)
d = dotenv('../config/blanklines.env');
assert(numel(fieldnames(d.env)) == 4);
testCase.verifyNumElements(fieldnames(d.env), 4);
end

function testEqualsInPassword(testCase)
d = dotenv('../config/equalPassword.env');
assert("s1mpl3=123" == d.env.DB_PASS);
testCase.verifyEqual("s1mpl3=123", d.env.DB_PASS);
end

function testWhitespaceValue(testCase)
d = dotenv('../config/whitespace.env');
assert("localhost server" == d.env.DB_HOST);
testCase.verifyEqual("localhost server", d.env.DB_HOST);
end

function testEmptyValue(testCase)
d = dotenv('../config/empty.env');
assert("" == d.env.DB_HOST);
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');
assert("george" == d.env.DB_USER);
testCase.verifyEqual(d.env.DB_USER, "george");
end

function testQuotedValues(testCase)
d = dotenv('../config/whitespace.env');
assert('" mypass "' == d.env.DB_PASS);
testCase.verifyEqual(d.env.DB_PASS, """ mypass """);
end

function testSingleValue(testCase)
d = dotenv('../config/single.env');
assert("localhost" == d.env.DB_HOST);
testCase.verifyEqual(d.env.DB_HOST, "localhost");
end


4 changes: 2 additions & 2 deletions tests/valueRetrieveTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

function testValidData(testCase)
d = dotenv();
assert(d.env.DB_HOST == "localhost");
testCase.verifyEqual(d.env.DB_HOST,"localhost");
end


function testInvalidName(testCase)
d = dotenv();
assert(d.env.DB_HOSED == ""); % doesn't exist
testCase.verifyEqual(d.env.DB_HOSED, "", 'DB_HOSED variable doesn''t exist');
end

0 comments on commit 9127262

Please sign in to comment.