
    +                         d dl Z d dlZd dlZd dlmZ e j
                  j                  e j
                  j                  e            Z G d dej                        Z
edk(  r ej                          yy)    N)testutilc                   T     e Zd Z fdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Z xZS )RuntimeTestsc                 @    t         | _        t        t        |           y )N)RUNTIME_DEF_ROOTruntime_def_rootsuperr   setUp)self	__class__s    ,platform/ext-runtime/go/test/runtime_test.pyr
   zRuntimeTests.setUp   s     0lD')    c                     | j                  t        j                  j                  t        j                  j	                  | j
                  |                   y)z9Asserts that the relative path 'filename' does not exist.N)assertFalseospathexistsjoin	temp_path)r   filenames     r   assert_no_filezRuntimeTests.assert_no_file   s0    T^^X(NOPr   c                     | j                  dd       | j                  | j                                | j                  t	        j
                  | j                        dg       y )Nz	foo.notgopackage main
func main)
write_filer   generate_configsassertEqualr   listdirr   r   s    r   test_go_files_no_goz RuntimeTests.test_go_files_no_go"   sG    %>?..01DNN3k]Cr   c                    | j                  dd       | j                          t        | j                  d            5 }t	        j
                  |      }d d d        | j                  ddd       | j                  d       | j                  d       | j                  d	
       | j                  d| j                  dd             | j                  d| j                  dd             y # 1 sw Y   xY w)Nfoo.gor   app.yamlgoflexruntimeenv
Dockerfile.dockerignoreTdeploydatadockerignore)
r   r   open	full_pathyamlloadr   r    assert_file_exists_with_contentsread_runtime_def_file)r   fcontentss      r   test_go_files_with_goz"RuntimeTests.test_go_files_with_go'   s    ";<$..,-yy|H .%)&9	; 	L)O,T*--&&v|<	> 	--&&v?	A .-s   C))C2c                    t        j                  t         j                  j                  | j                  d            }| j                  t         j                  j                  dd      d       | j                  d| j                                | j                  t         j                  j                  | j                  d                   y)z>Test go runtime does not recognize go files in subdirectories.subdirr!   r   Nr"   )r   mkdirr   r   r   r   r   r   r   r   r/   )r   subdir_paths     r   test_go_files_in_subdirsz%RuntimeTests.test_go_files_in_subdirs9   s    hhrww||DNNHEFXx81	3t4467z(BCDr   c                    | j                  dd       | j                          t        | j                  d            5 }t	        j
                  |      }ddd       | j                  ddd       | j                  d       | j                  d	       | j                  d
      }| j                  |d| j                  dd             | j                  |d	| j                  dd             y# 1 sw Y   xY w)z/Test generate_config_data with single .go file.r!   r   r"   Nr#   r$   r%   r(   r)   Tr*   r,   r-   )r   r   r.   r/   r0   r1   r   r   generate_config_data#assert_genfile_exists_with_contentsr3   )r   r4   r5   	cfg_filess       r   test_go_genfiles_with_goz%RuntimeTests.test_go_genfiles_with_goA   s    ";<$..,-yy|H .%)&9	; 	L)O,--T-:	00&&v|<	> 	00&&v~>	@ .-s   C++C4c                     | j                  dd       | j                  d       | j                  dd       | j                  d| j                  dd             | j                  d	| j                  dd
             y )Nr!   r   Tcustomr"   env: flex
runtime: go
r(   r,   r)   r-   )r   r   r2   r3   r   s    r   test_go_custom_runtimez#RuntimeTests.test_go_custom_runtimeV   s}    ";<T*--&	( 	--&&v|<	> 	--&&v~>	@r   c                     | j                  dd       | j                  d      }| j                  dd       | j                  |d| j	                  dd             | j                  |d	| j	                  dd
             y)z.Test generate_config_data with custom runtime.r!   r   TrB   r"   rD   r(   r,   r)   r-   N)r   r=   r2   r>   r3   )r   r?   s     r   test_go_custom_runtime_no_writez,RuntimeTests.test_go_custom_runtime_no_writec   s    ";<--T-:	--&	( 	00&&v|<	> 	00&&v?	Ar   c                     | j                  dd       t        j                  dd      }| j                  | j	                  |d             y )Nr!   r   r#      r%   Tappinfor+   r   r   AppInfoFake
assertTruer   r   configs     r   test_go_runtime_fieldz"RuntimeTests.test_go_runtime_fields   sL    ";<%% 	--f59 . ; 	<r   c                     | j                  dd       t        j                  dd      }| j                  | j	                  |d             y )Nr!   r   rC   rI   r%   TrJ   rL   rO   s     r   test_go_custom_runtime_fieldz)RuntimeTests.test_go_custom_runtime_field{   sL    ";<%% 	--f59 . ; 	<r   )__name__
__module____qualname__r
   r   r   r6   r;   r@   rE   rG   rQ   rS   __classcell__)r   s   @r   r   r      s<    *QD
A$E@*@A <<r   r   __main__)r   unittestr0   gae_ext_runtimer   r   dirname__file__r   TestBaser   rT   main r   r   <module>r`      sb    
   $77??277??8#<= i<8$$ i<X zHMMO r   