Skip to content

Commit fde71d2

Browse files
committed
revert connector tests
1 parent 5cbdeee commit fde71d2

File tree

1 file changed

+51
-23
lines changed

1 file changed

+51
-23
lines changed

internal/storage/clickhouse_connector_test.go

Lines changed: 51 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,22 @@ func TestMapClickHouseTypeToGoType(t *testing.T) {
1717
expectedType interface{}
1818
}{
1919
// Signed integers
20-
{"Int8", (*int8)(nil)},
20+
{"Int8", int8(0)},
2121
{"Nullable(Int8)", (**int8)(nil)},
22-
{"Int16", (*int16)(nil)},
22+
{"Int16", int16(0)},
2323
{"Nullable(Int16)", (**int16)(nil)},
24-
{"Int32", (*int32)(nil)},
24+
{"Int32", int32(0)},
2525
{"Nullable(Int32)", (**int32)(nil)},
26-
{"Int64", (*int64)(nil)},
26+
{"Int64", int64(0)},
2727
{"Nullable(Int64)", (**int64)(nil)},
2828
// Unsigned integers
29-
{"UInt8", (*uint8)(nil)},
29+
{"UInt8", uint8(0)},
3030
{"Nullable(UInt8)", (**uint8)(nil)},
31-
{"UInt16", (*uint16)(nil)},
31+
{"UInt16", uint16(0)},
3232
{"Nullable(UInt16)", (**uint16)(nil)},
33-
{"UInt32", (*uint32)(nil)},
33+
{"UInt32", uint32(0)},
3434
{"Nullable(UInt32)", (**uint32)(nil)},
35-
{"UInt64", (*uint64)(nil)},
35+
{"UInt64", uint64(0)},
3636
{"Nullable(UInt64)", (**uint64)(nil)},
3737
// Big integers
3838
{"Int128", big.NewInt(0)},
@@ -44,9 +44,9 @@ func TestMapClickHouseTypeToGoType(t *testing.T) {
4444
{"UInt256", big.NewInt(0)},
4545
{"Nullable(UInt256)", (**big.Int)(nil)},
4646
// Floating-point numbers
47-
{"Float32", (*float32)(nil)},
47+
{"Float32", float32(0)},
4848
{"Nullable(Float32)", (**float32)(nil)},
49-
{"Float64", (*float64)(nil)},
49+
{"Float64", float64(0)},
5050
{"Nullable(Float64)", (**float64)(nil)},
5151
// Decimal types
5252
{"Decimal", big.NewFloat(0)},
@@ -60,34 +60,34 @@ func TestMapClickHouseTypeToGoType(t *testing.T) {
6060
{"Decimal256", big.NewFloat(0)},
6161
{"Nullable(Decimal256)", (**big.Float)(nil)},
6262
// String types
63-
{"String", (*string)(nil)},
63+
{"String", ""},
6464
{"Nullable(String)", (**string)(nil)},
65-
{"FixedString(42)", (*string)(nil)},
65+
{"FixedString(42)", ""},
6666
{"Nullable(FixedString(42))", (**string)(nil)},
67-
{"UUID", (*string)(nil)},
67+
{"UUID", ""},
6868
{"Nullable(UUID)", (**string)(nil)},
69-
{"IPv4", (*string)(nil)},
69+
{"IPv4", ""},
7070
{"Nullable(IPv4)", (**string)(nil)},
71-
{"IPv6", (*string)(nil)},
71+
{"IPv6", ""},
7272
{"Nullable(IPv6)", (**string)(nil)},
7373
// Date and time types
74-
{"Date", (*time.Time)(nil)},
74+
{"Date", time.Time{}},
7575
{"Nullable(Date)", (**time.Time)(nil)},
76-
{"DateTime", (*time.Time)(nil)},
76+
{"DateTime", time.Time{}},
7777
{"Nullable(DateTime)", (**time.Time)(nil)},
78-
{"DateTime64", (*time.Time)(nil)},
78+
{"DateTime64", time.Time{}},
7979
{"Nullable(DateTime64)", (**time.Time)(nil)},
8080
// Enums
81-
{"Enum8('a' = 1, 'b' = 2)", (*string)(nil)},
81+
{"Enum8('a' = 1, 'b' = 2)", ""},
8282
{"Nullable(Enum8('a' = 1, 'b' = 2))", (**string)(nil)},
83-
{"Enum16('a' = 1, 'b' = 2)", (*string)(nil)},
83+
{"Enum16('a' = 1, 'b' = 2)", ""},
8484
{"Nullable(Enum16('a' = 1, 'b' = 2))", (**string)(nil)},
8585
// Arrays
8686
{"Array(Int32)", &[]*int64{}},
8787
{"Array(String)", &[]*string{}},
8888
{"Array(Float64)", &[]*float64{}},
8989
// LowCardinality
90-
{"LowCardinality(String)", (*string)(nil)},
90+
{"LowCardinality(String)", ""},
9191
{"LowCardinality(Nullable(String))", (**string)(nil)},
9292
// Unknown type
9393
{"UnknownType", new(interface{})},
@@ -101,8 +101,36 @@ func TestMapClickHouseTypeToGoType(t *testing.T) {
101101
expectedType := reflect.TypeOf(tc.expectedType)
102102
resultType := reflect.TypeOf(result)
103103

104-
if expectedType != resultType {
105-
t.Errorf("Expected type %v, got %v", expectedType, resultType)
104+
// Handle pointers
105+
if expectedType.Kind() == reflect.Ptr {
106+
if resultType.Kind() != reflect.Ptr {
107+
t.Errorf("Expected pointer type for dbType %s, got %s", tc.dbType, resultType.Kind())
108+
return
109+
}
110+
expectedElemType := expectedType.Elem()
111+
resultElemType := resultType.Elem()
112+
if expectedElemType.Kind() == reflect.Ptr {
113+
// Expected pointer to pointer
114+
if resultElemType.Kind() != reflect.Ptr {
115+
t.Errorf("Expected pointer to pointer for dbType %s, got %s", tc.dbType, resultElemType.Kind())
116+
return
117+
}
118+
expectedElemType = expectedElemType.Elem()
119+
resultElemType = resultElemType.Elem()
120+
}
121+
if expectedElemType != resultElemType {
122+
t.Errorf("Type mismatch for dbType %s: expected %s, got %s", tc.dbType, expectedElemType, resultElemType)
123+
}
124+
} else {
125+
// Non-pointer types
126+
if resultType.Kind() != reflect.Ptr {
127+
t.Errorf("Expected pointer type for dbType %s, got %s", tc.dbType, resultType.Kind())
128+
return
129+
}
130+
resultElemType := resultType.Elem()
131+
if expectedType != resultElemType {
132+
t.Errorf("Type mismatch for dbType %s: expected %s, got %s", tc.dbType, expectedType, resultElemType)
133+
}
106134
}
107135
})
108136
}

0 commit comments

Comments
 (0)