MCPcopy Create free account
hub / github.com/riverqueue/river / TestDefaultClientIDWithHost

Function TestDefaultClientIDWithHost

client_test.go:9352–9369  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9350}
9351
9352func TestDefaultClientIDWithHost(t *testing.T) {
9353 t.Parallel()
9354
9355 host, _ := os.Hostname()
9356 require.NotEmpty(t, host)
9357
9358 startedAt := time.Date(2024, time.March, 7, 4, 39, 12, 123456789, time.UTC)
9359
9360 require.Equal(t, "example_com_2024_03_07T04_39_12_123456", defaultClientIDWithHost(startedAt,
9361 "example.com"))
9362 require.Equal(t, "this_is_a_degenerately_long_host_name_that_will_be_truncated_2024_03_07T04_39_12_123456", defaultClientIDWithHost(startedAt,
9363 "this.is.a.degenerately.long.host.name.that.will.be.truncated.so.were.not.storing.massive.strings.to.the.database.com"))
9364
9365 // Test strings right around the boundary to make sure we don't have some off-by-one slice error.
9366 require.Equal(t, strings.Repeat("a", 59)+"_2024_03_07T04_39_12_123456", defaultClientIDWithHost(startedAt, strings.Repeat("a", 59)))
9367 require.Equal(t, strings.Repeat("a", 60)+"_2024_03_07T04_39_12_123456", defaultClientIDWithHost(startedAt, strings.Repeat("a", 60)))
9368 require.Equal(t, strings.Repeat("a", 60)+"_2024_03_07T04_39_12_123456", defaultClientIDWithHost(startedAt, strings.Repeat("a", 61)))
9369}
9370
9371// DriverPollOnly simulates a driver without a listener. An example of this is
9372// Postgres through `riverdatabasesql`, which is Postgres (so it can notify),

Callers

nothing calls this directly

Calls 1

defaultClientIDWithHostFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…