You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
test: add unit tests for lib/run dyno and fix colorize tests
Adds comprehensive unit tests for the Dyno class:
- Constructor default values and option handling
- _useSSH protocol detection (http/https vs other protocols)
- _env environment variable building and TERM handling
- _isDebug HEROKU_DEBUG environment variable checking
- _status dyno status formatting with name and size
- _readData exit code parsing and output handling
Also updates colorize.unit.test.ts:
- Uncomments existing tests that were previously disabled
- Updates color code constants to match current 256-color ANSI codes
- All 7 colorize test cases now pass
These changes improve coverage for src/lib/run which previously had 38.68% coverage and dyno.ts which had no dedicated test file.
@@ -21,12 +38,12 @@ describe('colorize', function () {
21
38
construnTest4=colorizeTest('run','State changed from starting to complete')
22
39
construnTest5=colorizeTest('run','Process exited with status 1')
23
40
construnTest6=colorizeTest('run','Process exited with status 0')
24
-
expect(runTest1).to.equal('\u001B[33m2018-01-01T00:00:00.00+00:00 heroku[run]:\u001B[39m \u001B[31mStopping all processes with SIGTERM\u001B[39m')
25
-
expect(runTest2).to.equal('\u001B[33m2018-01-01T00:00:00.00+00:00 heroku[run]:\u001B[39m Starting process with command \u001B[36m\u001B[1m`test-command`\u001B[22m\u001B[39m\u001B[32m by user test user\u001B[39m')
26
-
expect(runTest3).to.equal('\u001B[33m2018-01-01T00:00:00.00+00:00 heroku[run]:\u001B[39m State changed from \u001B[31mdown\u001B[39m to \u001B[92mup\u001B[39m')
27
-
expect(runTest4).to.equal('\u001B[33m2018-01-01T00:00:00.00+00:00 heroku[run]:\u001B[39m State changed from \u001B[93mstarting\u001B[39m to \u001B[92mcomplete\u001B[39m')
28
-
expect(runTest5).to.equal('\u001B[33m2018-01-01T00:00:00.00+00:00 heroku[run]:\u001B[39m Process exited with status \u001B[31m1\u001B[39m')
29
-
expect(runTest6).to.equal('\u001B[33m2018-01-01T00:00:00.00+00:00 heroku[run]:\u001B[39m Process exited with status \u001B[92m0\u001B[39m')
41
+
expect(runTest1).to.equal(`${colors.yellow}2018-01-01T00:00:00.00+00:00 heroku[run]:${colors.reset}${colors.red}Stopping all processes with SIGTERM${colors.reset}`)
42
+
expect(runTest2).to.equal(`${colors.yellow}2018-01-01T00:00:00.00+00:00 heroku[run]:${colors.reset} Starting process with command ${colors.bgGray}${colors.white}${colors.bold}\`test-command\`${colors.resetBold}${colors.reset}${colors.resetBg}${colors.green1} by user test user${colors.reset}`)
43
+
expect(runTest3).to.equal(`${colors.yellow}2018-01-01T00:00:00.00+00:00 heroku[run]:${colors.reset} State changed from ${colors.red}down${colors.reset} to ${colors.green1}up${colors.reset}`)
44
+
expect(runTest4).to.equal(`${colors.yellow}2018-01-01T00:00:00.00+00:00 heroku[run]:${colors.reset} State changed from ${colors.green2}starting${colors.reset} to ${colors.green1}complete${colors.reset}`)
45
+
expect(runTest5).to.equal(`${colors.yellow}2018-01-01T00:00:00.00+00:00 heroku[run]:${colors.reset} Process exited with status ${colors.red}1${colors.reset}`)
46
+
expect(runTest6).to.equal(`${colors.yellow}2018-01-01T00:00:00.00+00:00 heroku[run]:${colors.reset} Process exited with status ${colors.green1}0${colors.reset}`)
30
47
})
31
48
32
49
it('colorizes web logs',function(){
@@ -40,16 +57,16 @@ describe('colorize', function () {
40
57
constwebTest8=colorizeTest('web','Process exited with status 0')
expect(webTest3).to.equal('\u001B[36m2018-01-01T00:00:00.00+00:00 heroku[web]:\u001B[39m \u001B[31mStopping all processes with SIGTERM\u001B[39m')
46
-
expect(webTest4).to.equal('\u001B[36m2018-01-01T00:00:00.00+00:00 heroku[web]:\u001B[39m Starting process with command \u001B[36m\u001B[1m`test-command`\u001B[22m\u001B[39m\u001B[32m by user test user\u001B[39m')
47
-
expect(webTest5).to.equal('\u001B[36m2018-01-01T00:00:00.00+00:00 heroku[web]:\u001B[39m State changed from \u001B[31mdown\u001B[39m to \u001B[92mup\u001B[39m')
48
-
expect(webTest6).to.equal('\u001B[36m2018-01-01T00:00:00.00+00:00 heroku[web]:\u001B[39m State changed from \u001B[93mstarting\u001B[39m to \u001B[92mcomplete\u001B[39m')
49
-
expect(webTest7).to.equal('\u001B[36m2018-01-01T00:00:00.00+00:00 heroku[web]:\u001B[39m Process exited with status \u001B[31m1\u001B[39m')
50
-
expect(webTest8).to.equal('\u001B[36m2018-01-01T00:00:00.00+00:00 heroku[web]:\u001B[39m Process exited with status \u001B[92m0\u001B[39m')
expect(webTest3).to.equal(`${colors.cyan1}2018-01-01T00:00:00.00+00:00 heroku[web]:${colors.reset}${colors.red}Stopping all processes with SIGTERM${colors.reset}`)
63
+
expect(webTest4).to.equal(`${colors.cyan1}2018-01-01T00:00:00.00+00:00 heroku[web]:${colors.reset} Starting process with command ${colors.bgGray}${colors.white}${colors.bold}\`test-command\`${colors.resetBold}${colors.reset}${colors.resetBg}${colors.green1} by user test user${colors.reset}`)
64
+
expect(webTest5).to.equal(`${colors.cyan1}2018-01-01T00:00:00.00+00:00 heroku[web]:${colors.reset} State changed from ${colors.red}down${colors.reset} to ${colors.green1}up${colors.reset}`)
65
+
expect(webTest6).to.equal(`${colors.cyan1}2018-01-01T00:00:00.00+00:00 heroku[web]:${colors.reset} State changed from ${colors.green2}starting${colors.reset} to ${colors.green1}complete${colors.reset}`)
66
+
expect(webTest7).to.equal(`${colors.cyan1}2018-01-01T00:00:00.00+00:00 heroku[web]:${colors.reset} Process exited with status ${colors.red}1${colors.reset}`)
67
+
expect(webTest8).to.equal(`${colors.cyan1}2018-01-01T00:00:00.00+00:00 heroku[web]:${colors.reset} Process exited with status ${colors.green1}0${colors.reset}`)
expect(apiTest3).to.equal('\u001B[1m\u001B[32m2018-01-01T00:00:00.00+00:00 heroku[api]:\u001B[39m\u001B[22m Build started by user \u001B[32mtest-user\u001B[39m')
65
-
expect(apiTest4).to.equal('\u001B[1m\u001B[32m2018-01-01T00:00:00.00+00:00 heroku[api]:\u001B[39m\u001B[22m Deploy \u001B[36mtestApp\u001B[39m by user \u001B[32mtest-user\u001B[39m')
66
-
expect(apiTest5).to.equal('\u001B[1m\u001B[32m2018-01-01T00:00:00.00+00:00 heroku[api]:\u001B[39m\u001B[22m Release \u001B[35mv1\u001B[39m created by user \u001B[32mtest-user\u001B[39m')
67
-
expect(apiTest6).to.equal('\u001B[1m\u001B[32m2018-01-01T00:00:00.00+00:00 heroku[api]:\u001B[39m\u001B[22m Starting process with command \u001B[36m\u001B[1m`test-command`\u001B[22m\u001B[39m\u001B[32m by user test-user\u001B[39m')
expect(apiTest3).to.equal(`${colors.green2}2018-01-01T00:00:00.00+00:00 heroku[api]:${colors.reset} Build started by user ${colors.green1}test-user${colors.reset}`)
82
+
expect(apiTest4).to.equal(`${colors.green2}2018-01-01T00:00:00.00+00:00 heroku[api]:${colors.reset} Deploy ${colors.cyan1}testApp${colors.reset} by user ${colors.green1}test-user${colors.reset}`)
83
+
expect(apiTest5).to.equal(`${colors.green2}2018-01-01T00:00:00.00+00:00 heroku[api]:${colors.reset} Release ${colors.magenta1}v1${colors.reset} created by user ${colors.green1}test-user${colors.reset}`)
84
+
expect(apiTest6).to.equal(`${colors.green2}2018-01-01T00:00:00.00+00:00 heroku[api]:${colors.reset} Starting process with command ${colors.bgGray}${colors.white}${colors.bold}\`test-command\`${colors.resetBold}${colors.reset}${colors.resetBg}${colors.green1} by user test-user${colors.reset}`)
0 commit comments