mirror of
https://github.com/restic/restic.git
synced 2026-09-19 10:47:58 +00:00
Update dependencies
Among others, this updates minio-go, so that the new "eu-west-3" zone for AWS is supported.
This commit is contained in:
+111
-11
@@ -248,6 +248,14 @@ func reqField(name, typ string) *FieldSchema {
|
||||
}
|
||||
}
|
||||
|
||||
func optField(name, typ string) *FieldSchema {
|
||||
return &FieldSchema{
|
||||
Name: name,
|
||||
Type: FieldType(typ),
|
||||
Required: false,
|
||||
}
|
||||
}
|
||||
|
||||
func TestSimpleInference(t *testing.T) {
|
||||
testCases := []struct {
|
||||
in interface{}
|
||||
@@ -491,6 +499,37 @@ func TestRepeatedInference(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
type allNulls struct {
|
||||
A NullInt64
|
||||
B NullFloat64
|
||||
C NullBool
|
||||
D NullString
|
||||
E NullTimestamp
|
||||
F NullTime
|
||||
G NullDate
|
||||
H NullDateTime
|
||||
}
|
||||
|
||||
func TestNullInference(t *testing.T) {
|
||||
got, err := InferSchema(allNulls{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
want := Schema{
|
||||
optField("A", "INTEGER"),
|
||||
optField("B", "FLOAT"),
|
||||
optField("C", "BOOLEAN"),
|
||||
optField("D", "STRING"),
|
||||
optField("E", "TIMESTAMP"),
|
||||
optField("F", "TIME"),
|
||||
optField("G", "DATE"),
|
||||
optField("H", "DATETIME"),
|
||||
}
|
||||
if diff := testutil.Diff(got, want); diff != "" {
|
||||
t.Error(diff)
|
||||
}
|
||||
}
|
||||
|
||||
type Embedded struct {
|
||||
Embedded int
|
||||
}
|
||||
@@ -532,10 +571,11 @@ func TestRecursiveInference(t *testing.T) {
|
||||
|
||||
type withTags struct {
|
||||
NoTag int
|
||||
ExcludeTag int `bigquery:"-"`
|
||||
SimpleTag int `bigquery:"simple_tag"`
|
||||
UnderscoreTag int `bigquery:"_id"`
|
||||
MixedCase int `bigquery:"MIXEDcase"`
|
||||
ExcludeTag int `bigquery:"-"`
|
||||
SimpleTag int `bigquery:"simple_tag"`
|
||||
UnderscoreTag int `bigquery:"_id"`
|
||||
MixedCase int `bigquery:"MIXEDcase"`
|
||||
Nullable []byte `bigquery:",nullable"`
|
||||
}
|
||||
|
||||
type withTagsNested struct {
|
||||
@@ -544,6 +584,8 @@ type withTagsNested struct {
|
||||
ExcludeTag int `bigquery:"-"`
|
||||
Inside int `bigquery:"inside"`
|
||||
} `bigquery:"anon"`
|
||||
PNested *struct{ X int } // not nullable, for backwards compatibility
|
||||
PNestedNullable *struct{ X int } `bigquery:",nullable"`
|
||||
}
|
||||
|
||||
type withTagsRepeated struct {
|
||||
@@ -563,6 +605,7 @@ var withTagsSchema = Schema{
|
||||
reqField("simple_tag", "INTEGER"),
|
||||
reqField("_id", "INTEGER"),
|
||||
reqField("MIXEDcase", "INTEGER"),
|
||||
optField("Nullable", "BYTES"),
|
||||
}
|
||||
|
||||
func TestTagInference(t *testing.T) {
|
||||
@@ -589,6 +632,18 @@ func TestTagInference(t *testing.T) {
|
||||
Type: "RECORD",
|
||||
Schema: Schema{reqField("inside", "INTEGER")},
|
||||
},
|
||||
&FieldSchema{
|
||||
Name: "PNested",
|
||||
Required: true,
|
||||
Type: "RECORD",
|
||||
Schema: Schema{reqField("X", "INTEGER")},
|
||||
},
|
||||
&FieldSchema{
|
||||
Name: "PNestedNullable",
|
||||
Required: false,
|
||||
Type: "RECORD",
|
||||
Schema: Schema{reqField("X", "INTEGER")},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -666,12 +721,6 @@ func TestTagInferenceErrors(t *testing.T) {
|
||||
}{},
|
||||
err: errInvalidFieldName,
|
||||
},
|
||||
{
|
||||
in: struct {
|
||||
OmitEmpty int `bigquery:"abc,omitempty"`
|
||||
}{},
|
||||
err: errInvalidFieldName,
|
||||
},
|
||||
}
|
||||
for i, tc := range testCases {
|
||||
want := tc.err
|
||||
@@ -680,6 +729,13 @@ func TestTagInferenceErrors(t *testing.T) {
|
||||
t.Errorf("%d: inferring TableSchema: got:\n%#v\nwant:\n%#v", i, got, want)
|
||||
}
|
||||
}
|
||||
|
||||
_, err := InferSchema(struct {
|
||||
X int `bigquery:",optional"`
|
||||
}{})
|
||||
if err == nil {
|
||||
t.Error("got nil, want error")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSchemaErrors(t *testing.T) {
|
||||
@@ -721,7 +777,7 @@ func TestSchemaErrors(t *testing.T) {
|
||||
},
|
||||
{
|
||||
in: struct{ Ptr *int }{},
|
||||
err: errNoStruct,
|
||||
err: errUnsupportedFieldType,
|
||||
},
|
||||
{
|
||||
in: struct{ Interface interface{} }{},
|
||||
@@ -735,6 +791,14 @@ func TestSchemaErrors(t *testing.T) {
|
||||
in: struct{ MultiDimensional [][][]byte }{},
|
||||
err: errUnsupportedFieldType,
|
||||
},
|
||||
{
|
||||
in: struct{ SliceOfPointer []*int }{},
|
||||
err: errUnsupportedFieldType,
|
||||
},
|
||||
{
|
||||
in: struct{ SliceOfNull []NullInt64 }{},
|
||||
err: errUnsupportedFieldType,
|
||||
},
|
||||
{
|
||||
in: struct{ ChanSlice []chan bool }{},
|
||||
err: errUnsupportedFieldType,
|
||||
@@ -743,6 +807,42 @@ func TestSchemaErrors(t *testing.T) {
|
||||
in: struct{ NestedChan struct{ Chan []chan bool } }{},
|
||||
err: errUnsupportedFieldType,
|
||||
},
|
||||
{
|
||||
in: struct {
|
||||
X int `bigquery:",nullable"`
|
||||
}{},
|
||||
err: errBadNullable,
|
||||
},
|
||||
{
|
||||
in: struct {
|
||||
X bool `bigquery:",nullable"`
|
||||
}{},
|
||||
err: errBadNullable,
|
||||
},
|
||||
{
|
||||
in: struct {
|
||||
X struct{ N int } `bigquery:",nullable"`
|
||||
}{},
|
||||
err: errBadNullable,
|
||||
},
|
||||
{
|
||||
in: struct {
|
||||
X []int `bigquery:",nullable"`
|
||||
}{},
|
||||
err: errBadNullable,
|
||||
},
|
||||
{
|
||||
in: struct{ X *[]byte }{},
|
||||
err: errUnsupportedFieldType,
|
||||
},
|
||||
{
|
||||
in: struct{ X *[]int }{},
|
||||
err: errUnsupportedFieldType,
|
||||
},
|
||||
{
|
||||
in: struct{ X *int }{},
|
||||
err: errUnsupportedFieldType,
|
||||
},
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
want := tc.err
|
||||
|
||||
Reference in New Issue
Block a user