@@ -39,7 +39,7 @@ class Jekyll::NetlifyTest < Minitest::Test
3939 end
4040 end
4141
42- context 'netlify production deploy ' do
42+ context 'netlify production context ' do
4343 setup do
4444 Jekyll . instance_variable_set (
4545 :@logger , Jekyll ::LogAdapter . new ( Jekyll ::Stevenson . new , :error )
@@ -79,6 +79,7 @@ class Jekyll::NetlifyTest < Minitest::Test
7979
8080 should 'be production' do
8181 assert_equal 'production' , @site . config [ 'environment' ]
82+ assert_equal 'production' , @netlify [ 'environment' ]
8283 end
8384
8485 should 'not be a pull request' do
@@ -92,6 +93,39 @@ class Jekyll::NetlifyTest < Minitest::Test
9293 end
9394 end
9495 end
96+ context 'netlify deploy-preview context' do
97+ setup do
98+ Jekyll . instance_variable_set (
99+ :@logger , Jekyll ::LogAdapter . new ( Jekyll ::Stevenson . new , :error )
100+ )
101+
102+ ENV . clear
103+ ENV [ 'CONTEXT' ] = 'deploy-preview'
104+ ENV [ 'JEKYLL_ENV' ] = 'staging'
105+
106+ ENV [ 'PULL_REQUEST' ] = 'false'
107+ ENV [ 'DEPLOY_URL' ] = 'https://578ab634d5d5cf960d620--open-api.netlify.com'
108+ ENV [ 'DEPLOY_PRIME_URL' ] = 'https://beta--open-api.netlify.com'
109+
110+ config = Jekyll . configuration (
111+ source : jekyll_test_site ,
112+ destination : File . join ( jekyll_test_site , '_site' ) ,
113+ )
114+ @site = Jekyll ::Site . new ( config )
115+ @site . read
116+ @site . generate
117+ end
118+
119+ context 'info' do
120+ setup do
121+ @netlify = @site . config [ 'netlify' ]
122+ end
123+ should 'be staging-deploy-preview' do
124+ assert_equal 'staging' , @site . config [ 'environment' ]
125+ assert_equal 'staging-deploy-preview' , @netlify [ 'environment' ]
126+ end
127+ end
128+ end
95129
96130 context 'netlify unrecognised pull request' do
97131 setup do
@@ -131,8 +165,9 @@ class Jekyll::NetlifyTest < Minitest::Test
131165 assert_equal 'https://example.com' , @netlify [ 'url' ]
132166 end
133167
134- should 'not be production' do
135- assert_operator @site . config [ 'environment' ] , :!= , 'production'
168+ should 'be production' do
169+ assert_equal 'production' , @site . config [ 'environment' ]
170+ assert_equal 'production-deploy-preview' , @netlify [ 'environment' ]
136171 end
137172
138173 should 'be a pull request' do
0 commit comments