Sha256: ebe715b17e306e21ab5a09e8292cb3f1928388c09f32654a9406e8bf080e3d39

Contents?: true

Size: 1.8 KB

Versions: 4

Compression:

Stored size: 1.8 KB

Contents

package org.embulk.input.bigquery_export_gcs;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assume.assumeNotNull;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;

import org.embulk.EmbulkTestRuntime;
import org.embulk.config.ConfigSource;
import org.embulk.spi.Exec;
import org.embulk.spi.FileInputRunner;
import org.embulk.spi.TestPageBuilderReader.MockPageOutput;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class TestPluginFunctions extends UnitTestInitializer
{
	private static final Logger log = LoggerFactory.getLogger(TestPluginFunctions.class);
		
    @Test
    public void regexTest(){
    	testTableName("select * from aaa.bbb","bbb");
    	testTableName("select * from aaa.bbb.ccc","ccc");
    	testTableName("select * from [aaa.bbb]","bbb");
    	testTableName("select * from aaa.bbb$20171123","bbb");
    	testTableName("select * from aaa.t_b_b_b","t_b_b_b");
    }
    
    public void testTableName(String query, String expect){
    	String word = BigqueryExportUtils.parseQueryToBaseTableName(query);
    	log.info("{}", word );
    	assertEquals(word, expect);
    }

    @Test
    public void testParseGcsUrl(){
    	ConfigSource c = config.deepCopy();
    	c.set("gcs_uri", "gs://aaa/bbb/ccc_*");
    	
    	BigqueryExportGcsFileInputPlugin.PluginTask task = c.loadConfig(BigqueryExportGcsFileInputPlugin.PluginTask.class );
    	
    	BigqueryExportUtils.parseGcsUri(task);
    	
    	assertEquals("", "aaa", task.getGcsBucket());
    	assertEquals("", "bbb/ccc_", task.getGcsBlobNamePrefix());
    }

}

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
embulk-input-bigquery_extract_files-0.0.12 src/test/java/org/embulk/input/bigquery_export_gcs/TestPluginFunctions.java
embulk-input-bigquery_extract_files-0.0.11 src/test/java/org/embulk/input/bigquery_export_gcs/TestPluginFunctions.java
embulk-input-bigquery_extract_files-0.0.10 src/test/java/org/embulk/input/bigquery_export_gcs/TestPluginFunctions.java
embulk-input-bigquery_extract_files-0.0.9 src/test/java/org/embulk/input/bigquery_export_gcs/TestPluginFunctions.java