Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Mryashbhardwaj committed Dec 27, 2024
1 parent 34cd48b commit 3a192ef
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
1 change: 0 additions & 1 deletion ext/sheets/gsheet/gsheet.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ func (gs *GSheets) getSheetContent(sheetID, sheetRange string) ([][]interface{},
batchGetCall = batchGetCall.Ranges(sheetRange)
}
resp, err := batchGetCall.Do()

if err != nil {
return nil, err
}
Expand Down
10 changes: 7 additions & 3 deletions ext/store/maxcompute/external_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type McExternalTable interface {
hints, alias map[string]string,
) error
BatchLoadTables(tableNames []string) ([]*odps.Table, error)
Delete(tableName string, ifExists bool) error
}

type ExternalTableHandle struct {
Expand Down Expand Up @@ -53,9 +54,12 @@ func (e ExternalTableHandle) Create(res *resource.Resource) error {
return nil
}

func (ExternalTableHandle) Update(_ *resource.Resource) error {
// TODO implement me
panic("implement me")
func (e ExternalTableHandle) Update(res *resource.Resource) error {
err := e.mcExternalTable.Delete(res.FullName(), true)
if err != nil {
return err
}
return e.Create(res)
}

func (e ExternalTableHandle) Exists(tableName string) bool {
Expand Down
12 changes: 9 additions & 3 deletions ext/store/maxcompute/external_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,9 @@ func TestExternalTableHandle(t *testing.T) {

defer schema.AssertExpectations(t)
odpsIns := new(mockOdpsIns)

odpsIns.On("SetCurrentSchemaName", mock.Anything)
defer odpsIns.AssertExpectations(t)

tableHandle := maxcompute.NewExternalTableHandle(odpsIns, schema, table)

res, err := resource.NewResource(fullName, maxcompute.KindExternalTable, mcStore, tnnt, &metadata, spec)
Expand All @@ -104,7 +105,7 @@ func TestExternalTableHandle(t *testing.T) {

defer schema.AssertExpectations(t)
odpsIns := new(mockOdpsIns)

odpsIns.On("SetCurrentSchemaName", mock.Anything)
defer odpsIns.AssertExpectations(t)
tableHandle := maxcompute.NewExternalTableHandle(odpsIns, schema, table)

Expand All @@ -123,7 +124,7 @@ func TestExternalTableHandle(t *testing.T) {

defer schema.AssertExpectations(t)
odpsIns := new(mockOdpsIns)

odpsIns.On("SetCurrentSchemaName", mock.Anything)
defer odpsIns.AssertExpectations(t)
tableHandle := maxcompute.NewExternalTableHandle(odpsIns, schema, table)

Expand Down Expand Up @@ -174,6 +175,11 @@ func (m *mockExternalTable) CreateExternal(schema tableschema.TableSchema, creat
return args.Error(0)
}

func (m *mockExternalTable) Delete(tableName string, ifExists bool) error {
args := m.Called(tableName, ifExists)
return args.Error(0)
}

func (m *mockExternalTable) BatchLoadTables(tableNames []string) ([]*odps.Table, error) {
args := m.Called(tableNames)
if args.Get(0) == nil {
Expand Down
4 changes: 4 additions & 0 deletions ext/store/maxcompute/table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ func (m *mockOdpsIns) CurrentSchemaName() string {
return args.String(0)
}

func (m *mockOdpsIns) SetCurrentSchemaName(schemaName string) {
m.Called(schemaName)
}

func TestTableHandle(t *testing.T) {
accessID, accessKey, endpoint := "LNRJ5tH1XMSINW5J3TjYAvfX", "lAZBJhdkNbwVj3bej5BuhjwbdV0nSp", "http://service.ap-southeast-5.maxcompute.aliyun.com/api"
projectName, schemaName, tableName := "proj", "schema", "test_table"
Expand Down

0 comments on commit 3a192ef

Please sign in to comment.