Fix wrong key for initial language write, add test
This commit is contained in:
parent
26b32a8b93
commit
604f3103c7
@ -2196,7 +2196,7 @@ func (h *MenuHandlers) persistInitialLanguageCode(ctx context.Context, sessionId
|
|||||||
if !db.IsNotFound(err) {
|
if !db.IsNotFound(err) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = store.WriteEntry(ctx, sessionId, storedb.DATA_SELECTED_LANGUAGE_CODE, []byte(code))
|
err = store.WriteEntry(ctx, sessionId, storedb.DATA_INITIAL_LANGUAGE_CODE, []byte(code))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logg.ErrorCtxf(ctx, "failed to persist initial language code", "key", storedb.DATA_INITIAL_LANGUAGE_CODE, "value", code, "error", err)
|
logg.ErrorCtxf(ctx, "failed to persist initial language code", "key", storedb.DATA_INITIAL_LANGUAGE_CODE, "value", code, "error", err)
|
||||||
return err
|
return err
|
||||||
|
@ -825,6 +825,17 @@ func TestSetLanguage(t *testing.T) {
|
|||||||
|
|
||||||
// Assert that the Result FlagSet has the required flags after language switch
|
// Assert that the Result FlagSet has the required flags after language switch
|
||||||
assert.Equal(t, res, tt.expectedResult, "Result should match expected result")
|
assert.Equal(t, res, tt.expectedResult, "Result should match expected result")
|
||||||
|
code, err := store.ReadEntry(ctx, sessionId, storedb.DATA_SELECTED_LANGUAGE_CODE)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.Equal(t, string(code), tt.expectedResult.Content)
|
||||||
|
code, err = store.ReadEntry(ctx, sessionId, storedb.DATA_INITIAL_LANGUAGE_CODE)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
assert.Equal(t, string(code), "eng")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user