
    G                         S SK r S SKrS SKJr  \ R                  R                  \ R                  R                  \5      5      rSr " S S\R                  5      r
\S:X  a  \R                  " 5         gg)    N)testutila  # This Dockerfile for a Ruby application was generated by gcloud.

# The base Dockerfile installs:
# * A number of packages needed by the Ruby runtime and by gems
#   commonly used in Ruby web apps (such as libsqlite3)
# * A recent version of NodeJS
# * A recent version of the standard Ruby runtime to use by default
# * The bundler gem
FROM gcr.io/google-appengine/ruby:{base_image_tag}

# If your application requires a specific ruby version (compatible with rbenv),
# set it here. Leave blank to use the currently recommended default.
ARG REQUESTED_RUBY_VERSION="{ruby_version}"

# Install any requested ruby if not already preinstalled by the base image.
# Tries installing a prebuilt package first, then falls back to a source build.
RUN if test -n "$REQUESTED_RUBY_VERSION" -a \
        ! -x /rbenv/versions/$REQUESTED_RUBY_VERSION/bin/ruby; then \
      (apt-get update -y \
        && apt-get install -y -q gcp-ruby-$REQUESTED_RUBY_VERSION) \
      || (cd /rbenv/plugins/ruby-build \
        && git pull \
        && rbenv install -s $REQUESTED_RUBY_VERSION) \
      && rbenv global $REQUESTED_RUBY_VERSION \
      && gem install -q --no-rdoc --no-ri bundler --version $BUNDLER_VERSION \
      && apt-get clean \
      && rm -f /var/lib/apt/lists/*_*; \
    fi
ENV RBENV_VERSION=${{REQUESTED_RUBY_VERSION:-$RBENV_VERSION}}

# Copy the application files.
COPY . /app/

# Install required gems if Gemfile.lock is present.
RUN if test -f Gemfile.lock; then \
      bundle install --deployment --without="development test" \
      && rbenv rehash; \
    fi

# Temporary. Will be moved to base image later.
ENV RACK_ENV=production \
    RAILS_ENV=production \
    RAILS_SERVE_STATIC_FILES=true

# Run asset pipeline if we're in a Rails app.
RUN if test -d app/assets -a -f config/application.rb; then \
      bundle exec rake assets:precompile || true; \
    fi

# BUG: Reset entrypoint to override base image.
ENTRYPOINT []

# Start application on port $PORT.
CMD {entrypoint}
c                      ^  \ rS rSrSrS rS rU 4S jrS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rS rS rSrU =r$ )RuntimeTestCaseR   z2Tests for the Ruby external runtime fingerprinter.c                     [        U R                  U5      5       nUR                  5       sSSS5        $ ! , (       d  f       g= f)zReads the contents of the file from the tempdir.

Args:
    filename: (str) filename to be joined with tempdir prefix.

Returns:
    File contents.
N)open	full_pathread)selffilenamefs      .platform/ext-runtime/ruby/test/runtime_test.pyfile_contentsRuntimeTestCase.file_contentsU   s,     $..*+q668 ,++s	   5
Ac                    ^ ^^^ T R                   R                  mT R                   R                  mUUU 4S jnS T R                   l        U4S jT R                   l        U$ )zStubs the console response from the user.

Args:
    response: (str) stubbed response.

Returns:
    A function to reset the stubbed functions to their original
    implementations.
c                  J   > T TR                   l        TTR                   l        g Nexec_env	CanPromptPromptResponse)
can_promptprompt_responser   s   r   unstub-RuntimeTestCase.stub_response.<locals>.unstubn   s    &0DMM#+:DMM(    c                      g)NT r   r   r   <lambda>/RuntimeTestCase.stub_response.<locals>.<lambda>r   s    $r   c                    > T$ r   r   )promptresponses    r   r   r    s   s    hr   r   )r   r#   r   r   r   s   `` @@r   stub_responseRuntimeTestCase.stub_responsea   sG     ]],,
--66	; #/'>$r   c                 @   > [         U l        [        [        U ]  5         g r   )RUNTIME_DEF_ROOTruntime_def_rootsuperr   setUp)r   	__class__s    r   r*   RuntimeTestCase.setUpw   s     0ot*,r   c                    U R                  SS5        U R                  5         U R                  [        R                  R                  U R                  S5      5      5        U R                  [        R                  R                  U R                  S5      5      5        U R                  [        R                  R                  U R                  S5      5      5        g )N
index.htmlindexapp.yaml
Dockerfile.dockerignore)
write_filegenerate_configsassertFalseospathexistsr	   r   s    r    test_generate_without_ruby_files0RuntimeTestCase.test_generate_without_ruby_files{   s    g.z(BCD|(DEF(GHIr   c                     U R                  SS5        U R                  U R                  5       5        U R                  [        R
                  R                  U R                  S5      5      5        g)z9Tests generate_config_data does nothing if no ruby files.r.   r/   r0   N)r3   assertIsNonegenerate_config_datar5   r6   r7   r8   r	   r9   s    r   )test_generate_without_ruby_files_no_write9RuntimeTestCase.test_generate_without_ruby_files_no_write   sK    g.$3356z(BCDr   c                 B   U R                  SS5        U R                  SS5        U R                  SS5        U R                  S5      nU R                  5         U" 5         U R                  S5      nU R	                  S	U5        U R	                  S
U5        U R	                  SU5        U R                  [        R                  R                  U R                  S5      5      5        U R                  [        R                  R                  U R                  S5      5      5        g )Nindex.rbclass Index; endGemfilesource "https://rubygems.org"	config.rurun Index.app)bundle exec rackup -p $PORT -E deploymentr0   runtime: ruby

env: flex
6entrypoint: bundle exec rackup -p $PORT -E deployment
r1   r2   )
r3   r$   r4   r   assertInr5   r6   r7   r8   r	   )r   r   app_yamls      r   test_generate_with_ruby_files-RuntimeTestCase.test_generate_with_ruby_files   s    
$67	#BC_5##$OP%%j1'2mX.O	  	|(DEF(GHIr   c                    U R                  SS5        U R                  SS5        U R                  SS5        U R                  S5      nU R                  5       nU" 5         U R                  S5      nU R	                  S	U5        U R	                  S
U5        U R	                  SU5        U R                  SU Vs/ s H  oDR                  PM     sn5        U R                  SU Vs/ s H  oDR                  PM     sn5        gs  snf s  snf )zTests generate_config_data with basic Ruby files.

Tests that app.yaml is written with correct contents given entrypoint
response, and that Dockerfile and .dockerignore not written to disk.
rB   rC   rD   rE   rF   rG   rH   r0   rI   rJ   rK   r1   r2   N)r3   r$   r>   r   rL   assertNotInr   )r   r   	cfg_filesrM   r   s        r   &test_generate_with_ruby_files_no_write6RuntimeTestCase.test_generate_with_ruby_files_no_write   s     	
$67	#BC_5##$OP--/	%%j1'2mX.O	  	I'FIq

I'FGy*Iy!::y*IJ (G*Is   6C?
"D
c                 "   U R                  SS5        U R                  SS5        U R                  SS5        U R                  SS5        U R                  S	5      nU R                  S
S9  U" 5         U R                  S5      nU R	                  U[
        R                  SS	S95        U R                  S5      nU R                  SU5        U R                  SU5        U R                  SU5        U R                  SU5        U R                  SU5        g )NrB   rC   rD   rE   rF   rG   .ruby-versionrbx-3.9rH   Tdeployr1   ruby_version
entrypointr2   .dockerignore
Dockerfile
.git
.hg
.svn
r3   r$   r4   r   assertEqualDOCKERFILE_TEXTformatrL   r   r   
dockerfiledockerignores       r   test_generate_with_deploy)RuntimeTestCase.test_generate_with_deploy   s    
$67	#BC_53##$OPT*''5
&&%.#N ' P	Q ))/:'6nl3h-g|,h-r   c           	         U R                  SS5        U R                  SS5        U R                  SS5        U R                  SS5        U R                  S	5      nU R                  S
S9nU" 5         U R                  US[        R                  SS	S95        U R                  SU Vs/ s H  o3R                  PM     sn5        U Vs/ s H!  nUR                  S:X  d  M  UR                  PM#     snS   nU R                  SU5        U R                  SU5        U R                  SU5        U R                  SU5        U R                  SU5        gs  snf s  snf )zTests generate_config_data with deploy=True.

Tests that .dockerignore and Dockerfile contents are correct
based on contents of app.
rB   rC   rD   rE   rF   rG   rV   rW   rH   TrX   r1   rZ   r2   r   r]   r^   r_   r`   ra   N	r3   r$   r>   #assert_genfile_exists_with_contentsrd   re   rL   r   contentsr   r   rR   r   rh   s        r   "test_generate_with_deploy_no_write2RuntimeTestCase.test_generate_with_deploy_no_write   s>    	
$67	#BC_53##$OP--T-:	00&&%.#N ' P	Q 	oI'FIq

I'FG,5 7Iq

o5 #

I 778:'6nl3h-g|,h- (G7s   %E
EEc                    U R                  SS5        U R                  SS5        U R                  SS5        U R                  S5      nU R                  SS	9  U" 5         U R                  S
5      nU R	                  SU5        U R	                  SU5        U R	                  SU5        U R                  S5      nU R                  U[        R                  SSS95        U R                  S5      nU R	                  SU5        U R	                  SU5        U R	                  SU5        U R	                  SU5        U R	                  SU5        g )NrB   rC   rD   rE   rF   rG   rH   Tcustomr0   runtime: custom
rJ   rK   r1    rZ   r2   r]   r^   r_   r`   ra   )r3   r$   r4   r   rL   rc   rd   re   )r   r   rM   rg   rh   s        r   test_generate_with_custom)RuntimeTestCase.test_generate_with_custom   s+   
$67	#BC_5##$OPT*%%j1)84mX.O	  ''5
&&%'#N ' P	Q ))/:'6nl3h-g|,h-r   c           	         U R                  SS5        U R                  SS5        U R                  SS5        U R                  S5      nU R                  SS	9nU" 5         U R                  S
5      nU R	                  SU5        U R	                  SU5        U R	                  SU5        U R                  US[        R                  SSS95        U R	                  SU Vs/ s H  oDR                  PM     sn5        U Vs/ s H!  nUR                  S:X  d  M  UR                  PM#     snS   nU R	                  SU5        U R	                  SU5        U R	                  SU5        U R	                  SU5        U R	                  SU5        gs  snf s  snf )zTests generate_config_data with custom=True.

Tests that app.yaml is written with correct parameters and
Dockerfile, .dockerignore contents are correctly returned by method.
rB   rC   rD   rE   rF   rG   rH   Trs   r0   ru   rJ   rK   r1   rv   rZ   r2   r   r]   r^   r_   r`   ra   N)
r3   r$   r>   r   rL   rm   rd   re   r   rn   )r   r   rR   rM   r   rh   s         r   "test_generate_with_custom_no_write2RuntimeTestCase.test_generate_with_custom_no_write	  sq    	
$67	#BC_5##$OP--T-:	%%j1)84mX.O	  	00&&%'#N ' P	Q 	oI'FIq

I'FG,5 7Iq

o5 #

I 778:'6nl3h-g|,h- (G7s   F
:FFc                 v   U R                  SS5        U R                  SS5        U R                  SS5        [        R                  " SSS	S
9nU R                  US	S9  U R	                  [
        R                  R                  U R                  S5      5      5        U R                  S5      nU R                  U[        R                  SSS95        U R                  S5      nU R                  SU5        U R                  SU5        U R                  SU5        U R                  SU5        U R                  SU5        g )NrB   rC   rD   rE   rF   rG   bundle exec ruby index.rb $PORTrubyTr\   runtimevmappinforY   r0   r1   rv   rZ   r2   r]   r^   r_   r`   ra   r3   r   AppInfoFaker4   r5   r6   r7   r8   r	   r   rc   rd   re   rL   r   r   rg   rh   s       r   #test_generate_with_existing_appinfo3RuntimeTestCase.test_generate_with_existing_appinfo-  s   
$67	#BC_5&&< 	gd;z(BCD''5
&&%'#D ' F	G ))/:'6nl3h-g|,h-r   c           	         U R                  SS5        U R                  SS5        U R                  SS5        [        R                  " SSS	S
9nU R                  US	S9nU R	                  [
        R                  R                  U R                  S5      5      5        U R                  US[        R                  SSS95        U R                  SU Vs/ s H  o3R                  PM     sn5        U Vs/ s H!  nUR                  S:X  d  M  UR                  PM#     snS   nU R                  SU5        U R                  SU5        U R                  SU5        U R                  SU5        U R                  SU5        gs  snf s  snf )z/Tests generate_config_data with passed appinfo.rB   rC   rD   rE   rF   rG   r}   r~   Tr   r   r0   r1   rv   rZ   r2   r   r]   r^   r_   r`   ra   Nr3   r   r   r>   r5   r6   r7   r8   r	   rm   rd   re   rL   r   rn   r   r   rR   r   rh   s        r   ,test_generate_with_existing_appinfo_no_write<RuntimeTestCase.test_generate_with_existing_appinfo_no_writeG  sY   
$67	#BC_5&&< --gd-K	z(BCD00&&%'#D ' F	G 	oI'FIq

I'FG,5 7Iq

o5 #

I 778:'6nl3h-g|,h- (G7s   E8
/E=E=c                    U R                  SS5        U R                  SS5        U R                  SS5        U R                  SS5        [        R                  " S	S
SS9nU R                  USS9  U R	                  [
        R                  R                  U R                  S5      5      5        U R                  S5      nU R                  U[        R                  SS	S95        U R                  S5      nU R                  SU5        U R                  SU5        U R                  SU5        U R                  SU5        U R                  SU5        g )NrB   rC   rD   rE   rF   rG   rV   2.3.1
r}   r~   Tr   r   r0   r1   2.3.1rZ   r2   r]   r^   r_   r`   ra   r   r   s       r   test_generate_with_ruby_version/RuntimeTestCase.test_generate_with_ruby_versiond  s#   
$67	#BC_53&&< 	gd;z(BCD''5
&&%,#D ' F	G ))/:'6nl3h-g|,h-r   c           	      (   U R                  SS5        U R                  SS5        U R                  SS5        U R                  SS5        [        R                  " S	S
SS9nU R                  USS9nU R	                  [
        R                  R                  U R                  S5      5      5        U R                  US[        R                  SS	S95        U R                  SU Vs/ s H  o3R                  PM     sn5        U Vs/ s H!  nUR                  S:X  d  M  UR                  PM#     snS   nU R                  SU5        U R                  SU5        U R                  SU5        U R                  SU5        U R                  SU5        gs  snf s  snf )z3Tests generate_config_data with .ruby-version file.rB   rC   rD   rE   rF   rG   rV   r   r}   r~   Tr   r   r0   r1   r   rZ   r2   r   r]   r^   r_   r`   ra   Nr   r   s        r   (test_generate_with_ruby_version_no_write8RuntimeTestCase.test_generate_with_ruby_version_no_write  sg   
$67	#BC_53&&< --gd-K	z(BCD00&&%,#D ' F	G 	oI'FIq

I'FG,5 7Iq

o5 #

I 778:'6nl3h-g|,h- (G7s   !F

FFc                    U R                  SS5        U R                  SS5        U R                  S5      nU R                  SS9  U" 5         U R                  S5      nU R	                  U[
        R                  S	SS
95        U R                  S5      nU R                  SU5        U R                  SU5        U R                  SU5        U R                  SU5        U R                  SU5        g )NrB   rC   rD   rE   r}   TrX   r1   rv   rZ   r2   r]   r^   r_   r`   ra   rb   rf   s       r   test_generate_with_prompt)RuntimeTestCase.test_generate_with_prompt  s    
$67	#BC##$EFT*''5
&&%'#D ' F	G ))/:'6nl3h-g|,h-r   c           	      h   U R                  SS5        U R                  SS5        U R                  S5      nU R                  SS9nU" 5         U R                  US[        R                  S	SS
95        U R                  SU Vs/ s H  o3R                  PM     sn5        U Vs/ s H!  nUR                  S:X  d  M  UR                  PM#     snS   nU R                  SU5        U R                  SU5        U R                  SU5        U R                  SU5        U R                  SU5        gs  snf s  snf )z;Tests generate_config_data with entrypoint given by prompt.rB   rC   rD   rE   r}   TrX   r1   rv   rZ   r2   r   r]   r^   r_   r`   ra   Nrl   ro   s        r   "test_generate_with_prompt_no_write2RuntimeTestCase.test_generate_with_prompt_no_write  s    
$67	#BC##$EF--T-:	00&&%'#D ' F	G 	oI'FIq

I'FG,5 7Iq

o5 #

I 778:'6nl3h-g|,h- (G7s   D*
!D/9D/)r(   )__name__
__module____qualname____firstlineno____doc__r   r$   r*   r:   r?   rN   rS   ri   rp   rw   rz   r   r   r   r   r   r   __static_attributes____classcell__)r+   s   @r   r   r   R   se    <
,-JEJ$K..2.>.:".H.4.:.6.<.,. .r   r   __main__)r6   unittestgae_ext_runtimer   r7   dirname__file__r'   rd   TestBaser   r   mainr   r   r   <module>r      se     
  $77??277??8#<= 7tx.h'' x.t zmmo r   