This commit is contained in:
Anthony Miyaguchi 2019-01-17 13:39:42 -08:00
Родитель 506b604f64
Коммит 2d6f8ac45a
2 изменённых файлов: 59 добавлений и 35 удалений

Просмотреть файл

@ -9,11 +9,17 @@ use std::fs::{self, File};
use std::io::{BufReader, Write}; use std::io::{BufReader, Write};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
#[derive(Deserialize, Debug)]
struct TestData {
avro: Value,
bigquery: Value,
json: Value,
}
#[derive(Deserialize, Debug)] #[derive(Deserialize, Debug)]
struct TestCase { struct TestCase {
name: String, name: String,
avro: Value, test: TestData,
json: Value,
} }
#[derive(Deserialize, Debug)] #[derive(Deserialize, Debug)]
@ -59,8 +65,8 @@ fn {name}() {{
}} }}
"##, "##,
name = case.name, name = case.name,
input_data = format_json(case.json), input_data = format_json(case.test.json),
expected = format_json(case.avro), expected = format_json(case.test.avro),
); );
write!(outfile, "{}", formatted).unwrap() write!(outfile, "{}", formatted).unwrap()
} }

Просмотреть файл

@ -2,42 +2,60 @@
"name": "atomic", "name": "atomic",
"tests": [ "tests": [
{ {
"avro": { "name": "test_atomic",
"name": "root", "test": {
"type": "int" "avro": {
}, "name": "root",
"json": { "type": "int"
"type": "integer" },
}, "bigquery": {
"name": "test_atomic" "mode": "REQUIRED",
"type": "INTEGER"
},
"json": {
"type": "integer"
}
}
}, },
{ {
"avro": { "name": "test_atomic_with_null",
"name": "root", "test": {
"type": [ "avro": {
"int", "name": "root",
"null" "type": [
] "int",
}, "null"
"json": { ]
"type": [ },
"integer", "bigquery": {
"null" "mode": "NULLABLE",
] "type": "INTEGER"
}, },
"name": "test_atomic_with_null" "json": {
"type": [
"integer",
"null"
]
}
}
}, },
{ {
"name": "test_incompatible_atomic_multitype", "name": "test_incompatible_atomic_multitype",
"json": { "test": {
"type": [ "avro": {
"boolean", "type": "string"
"integer" },
] "bigquery": {
}, "mode": "REQUIRED",
"avro": { "type": "STRING"
"type": "string" },
"json": {
"type": [
"boolean",
"integer"
]
}
} }
} }
] ]
} }