1212from rest_framework .test import APITransactionTestCase
1313from unittest import mock
1414from rest_framework .authtoken .models import Token
15+ from test .support import EnvironmentVarGuard
1516
1617from api .models import App , Build , Release
1718
@@ -571,7 +572,7 @@ def test_run_command_good(self, mock_requests):
571572 entrypoint = json .loads (response .data ['output' ])['spec' ]['containers' ][0 ]['command' ][0 ]
572573 self .assertEqual (entrypoint , '/bin/bash' )
573574
574- # # docker image workflow
575+ # docker image workflow
575576 build .dockerfile = ''
576577 build .sha = ''
577578 build .save ()
@@ -582,7 +583,7 @@ def test_run_command_good(self, mock_requests):
582583 entrypoint = json .loads (response .data ['output' ])['spec' ]['containers' ][0 ]['command' ][0 ]
583584 self .assertEqual (entrypoint , '/bin/bash' )
584585
585- # # procfile workflow
586+ # procfile workflow
586587 build .sha = 'somereallylongsha'
587588 build .save ()
588589 url = "/v2/apps/{app_id}/run" .format (** locals ())
@@ -592,6 +593,49 @@ def test_run_command_good(self, mock_requests):
592593 entrypoint = json .loads (response .data ['output' ])['spec' ]['containers' ][0 ]['command' ][0 ]
593594 self .assertEqual (entrypoint , '/runner/init' )
594595
596+ def test_run_not_fail_on_debug (self , mock_requests ):
597+ """
598+ do a run with DEBUG on - https://github.com/deis/controller/issues/583
599+ """
600+ env = EnvironmentVarGuard ()
601+ env ['DEBUG' ] = 'true'
602+
603+ url = '/v2/apps'
604+ response = self .client .post (url )
605+ self .assertEqual (response .status_code , 201 )
606+ app_id = response .data ['id' ]
607+ app = App .objects .get (id = app_id )
608+
609+ # dockerfile + procfile worflow
610+ build = Build .objects .create (
611+ owner = self .user ,
612+ app = app ,
613+ image = "qwerty" ,
614+ procfile = {
615+ 'web' : 'node server.js' ,
616+ 'worker' : 'node worker.js'
617+ },
618+ dockerfile = 'foo' ,
619+ sha = 'somereallylongsha'
620+ )
621+
622+ # create an initial release
623+ Release .objects .create (
624+ version = 2 ,
625+ owner = self .user ,
626+ app = app ,
627+ config = app .config_set .latest (),
628+ build = build
629+ )
630+
631+ # create a run pod
632+ url = "/v2/apps/{app_id}/run" .format (** locals ())
633+ body = {'command' : 'echo hi' }
634+ response = self .client .post (url , body )
635+ self .assertEqual (response .status_code , 200 )
636+ entrypoint = json .loads (response .data ['output' ])['spec' ]['containers' ][0 ]['command' ][0 ]
637+ self .assertEqual (entrypoint , '/bin/bash' )
638+
595639 def test_scaling_does_not_add_run_proctypes_to_structure (self , mock_requests ):
596640 """Test that app info doesn't show transient "run" proctypes."""
597641 url = '/v2/apps'
0 commit comments