feat(GODT-2554): Compute telemetry availability from API UserSettings.

This commit is contained in:
Romain Le Jeune
2023-04-13 08:06:48 +00:00
parent c7ae239350
commit 3928ed08f6
7 changed files with 88 additions and 0 deletions

View File

@ -80,6 +80,23 @@ func TestUser_AddressMode(t *testing.T) {
})
}
func TestUser_Telemetry(t *testing.T) {
withAPI(t, context.Background(), func(ctx context.Context, s *server.Server, m *proton.Manager) {
withAccount(t, s, "username", "password", []string{}, func(string, []string) {
withUser(t, ctx, s, m, "username", "password", func(user *User) {
// By default, user should have Telemetry enabled.
telemetry := user.IsTelemetryEnabled(ctx)
require.Equal(t, true, telemetry)
user.client.Close()
// If telemetry cannot be retrieved it is disabled.
telemetry = user.IsTelemetryEnabled(ctx)
require.Equal(t, false, telemetry)
})
})
})
}
func withAPI(_ testing.TB, ctx context.Context, fn func(context.Context, *server.Server, *proton.Manager)) { //nolint:revive
server := server.New()
defer server.Close()