Skip to content

Commit

Permalink
Added tests for Config() functions
Browse files Browse the repository at this point in the history
GetAll,Get, GetWithDefault, Set,IsModifiable, Unset
  • Loading branch information
magpierre committed Oct 22, 2024
1 parent df1570f commit 551137a
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions internal/tests/integration/dataframe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -694,3 +694,59 @@ func TestDataFrame_FreqItems(t *testing.T) {
assert.NoErrorf(t, err, "%+v", err)
assert.Len(t, res, 1)
}

func TestDataFrame_Config_GetAll(t *testing.T) {
ctx, spark := connect()
result, err := spark.Config().GetAll(ctx)
assert.NoError(t, err, "%+v", err)
assert.Equal(t, "driver", (*result)["spark.executor.id"])
}

func TestDataFrame_Config_Get(t *testing.T) {
ctx, spark := connect()
keys := []string{
"spark.executor.id",
}
result, err := spark.Config().Get(ctx, keys)
assert.NoError(t, err, "%+v", err)
assert.Equal(t, "driver", (*result)["spark.executor.id"])
}

func TestDataFrame_Config_GetWithDefault(t *testing.T) {
ctx, spark := connect()
keys := map[string]string{
"spark.executor.id": "executor_id_not_set",
"spark.whatever": "whatever_not_set",
}
result, err := spark.Config().GetWithDefault(ctx, keys)
assert.NoError(t, err, "%+v", err)
assert.Equal(t, "driver", (*result)["spark.executor.id"])
assert.Equal(t, "whatever_not_set", (*result)["spark.whatever"])
}

func TestDataFrame_Config_Set(t *testing.T) {
ctx, spark := connect()
err := spark.Config().Set(ctx, "spark.whatever", "whatever_set")
assert.NoError(t, err, "%+v", err)
}

func TestDataFrame_Config_IsModifiable(t *testing.T) {
ctx, spark := connect()
keys := []string{
"spark.executor.id",
}
result, err := spark.Config().IsModifiable(ctx, keys)
assert.NoError(t, err, "%+v", err)
assert.Equal(t, "false", (*result)["spark.executor.id"])
}

func TestDataFrame_Config_Unset(t *testing.T) {
ctx, spark := connect()
keys := []string{
"spark.magnus",
}
err := spark.Config().Set(ctx, "spark.whatever", "whatever_set")
assert.NoError(t, err, "%+v", err)
err = spark.Config().Unset(ctx, keys)
assert.NoError(t, err, "%+v", err)
}

0 comments on commit 551137a

Please sign in to comment.