Skip to content

Commit

Permalink
fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
negrel committed Jan 23, 2024
1 parent db64e20 commit ff59e74
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 55 deletions.
20 changes: 10 additions & 10 deletions internal/config/load_env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func TestGetEnvOrDefault(t *testing.T) {

t.Run("UndefinedVar", func(t *testing.T) {
expected := "MY_ENV_VAR_VALUE"
actual := getEnvOrDefault("MY_ENV_VAR", expected)
actual := GetEnvOrDefault("MY_ENV_VAR", expected)

require.Equal(t, expected, actual)
})
Expand All @@ -22,7 +22,7 @@ func TestGetEnvOrDefault(t *testing.T) {
expected := "MY_ENV_VAR_VALUE"
os.Setenv("MY_ENV_VAR", expected)

actual := getEnvOrDefault("MY_ENV_VAR", "")
actual := GetEnvOrDefault("MY_ENV_VAR", "")

require.Equal(t, expected, actual)
})
Expand All @@ -32,7 +32,7 @@ func TestMustGetEnv(t *testing.T) {
os.Clearenv()
t.Run("UndefinedVar", func(t *testing.T) {
require.Panics(t, func() {
mustGetEnv("MY_ENV_VAR")
MustGetEnv("MY_ENV_VAR")
})
})

Expand All @@ -41,7 +41,7 @@ func TestMustGetEnv(t *testing.T) {
expected := "MY_ENV_VAR_VALUE"
os.Setenv("MY_ENV_VAR", expected)

actual := mustGetEnv("MY_ENV_VAR")
actual := MustGetEnv("MY_ENV_VAR")

require.Equal(t, expected, actual)
})
Expand All @@ -51,7 +51,7 @@ func TestParseUintEnvOrDefault(t *testing.T) {
os.Clearenv()
t.Run("UndefinedVar", func(t *testing.T) {
expected := uint64(42)
actual := parseUintEnvOrDefault("MY_ENV_VAR", expected, 64)
actual := ParseUintEnvOrDefault("MY_ENV_VAR", expected, 64)

require.Equal(t, expected, actual)
})
Expand All @@ -60,14 +60,14 @@ func TestParseUintEnvOrDefault(t *testing.T) {
t.Run("DefinedVar/NaN", func(t *testing.T) {
os.Setenv("MY_ENV_VAR", "NaN")
require.Panics(t, func() {
parseUintEnvOrDefault("MY_ENV_VAR", 42, 64)
ParseUintEnvOrDefault("MY_ENV_VAR", 42, 64)
})
})

os.Clearenv()
t.Run("DefinedVar/ValidUint", func(t *testing.T) {
os.Setenv("MY_ENV_VAR", "16")
actual := parseUintEnvOrDefault("MY_ENV_VAR", 42, 64)
actual := ParseUintEnvOrDefault("MY_ENV_VAR", 42, 64)
require.Equal(t, uint64(16), actual)
})
}
Expand All @@ -76,23 +76,23 @@ func TestMustParseUrlEnv(t *testing.T) {
os.Clearenv()
t.Run("UndefinedVar", func(t *testing.T) {
require.Panics(t, func() {
mustParseUrlEnv("MY_ENV_VAR")
MustParseUrlEnv("MY_ENV_VAR")
})
})

os.Clearenv()
t.Run("DefinedVar/InvalidUrl", func(t *testing.T) {
os.Setenv("MY_ENV_VAR", "")
require.Panics(t, func() {
mustParseUrlEnv("MY_ENV_VAR")
MustParseUrlEnv("MY_ENV_VAR")
})
})

os.Clearenv()
t.Run("DefinedVar/ValidUrl", func(t *testing.T) {
expected := "http://admin:[email protected]:443/path#fragment?query=q"
os.Setenv("MY_ENV_VAR", expected)
actual := mustParseUrlEnv("MY_ENV_VAR")
actual := MustParseUrlEnv("MY_ENV_VAR")
require.NotNil(t, actual)
require.Equal(t, expected, actual.String())
})
Expand Down
90 changes: 45 additions & 45 deletions tests/bun/default/events_pageviews.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,49 +12,49 @@ test('GET request instead of POST request', async () => {

test('invalid URL in X-Prisme-Referrer header', async () => {
const response = await fetch(PAGEVIEWS_ENDPOINT, {
method: "POST",
method: 'POST',
headers: {
"X-Prisme-Referrer": "not an url",
'X-Prisme-Referrer': 'not an url'
}
})
expect(response.status).toBe(400)
})

test('invalid URL in Referer header', async () => {
const response = await fetch(PAGEVIEWS_ENDPOINT, {
method: "POST",
method: 'POST',
headers: {
"Referer": "not an url",
Referer: 'not an url'
}
})
expect(response.status).toBe(400)
})

test('non registered domain in X-Prisme-Referrer header is rejected', async () => {
const response = await fetch(PAGEVIEWS_ENDPOINT, {
method: "POST",
method: 'POST',
headers: {
"X-Prisme-Referrer": "https://example.com/foo?bar=baz#qux",
'X-Prisme-Referrer': 'https://example.com/foo?bar=baz#qux'
}
})
expect(response.status).toBe(400)
})

test('non registered domain in Referer header is rejected', async () => {
const response = await fetch(PAGEVIEWS_ENDPOINT, {
method: "POST",
method: 'POST',
headers: {
"Referer": "https://example.com/foo?bar=baz#qux",
Referer: 'https://example.com/foo?bar=baz#qux'
}
})
expect(response.status).toBe(400)
})

test('valid URL with registered domain in X-Prisme-Referrer header is accepted', async () => {
const response = await fetch(PAGEVIEWS_ENDPOINT, {
method: "POST",
method: 'POST',
headers: {
"X-Prisme-Referrer": "http://mywebsite.localhost/foo?bar=baz#qux"
'X-Prisme-Referrer': 'http://mywebsite.localhost/foo?bar=baz#qux'
}
})
expect(response.status).toBe(200)
Expand All @@ -63,32 +63,32 @@ test('valid URL with registered domain in X-Prisme-Referrer header is accepted',
Bun.sleepSync(1000)

const client = createClient({
host: "http://clickhouse.localhost:8123",
username: "clickhouse",
password: "password",
database: "prisme",
host: 'http://clickhouse.localhost:8123',
username: 'clickhouse',
password: 'password',
database: 'prisme'
})

const rows = await client.query({
query: `SELECT * FROM prisme.events_pageviews ORDER BY timestamp DESC LIMIT 1;`
query: 'SELECT * FROM prisme.events_pageviews ORDER BY timestamp DESC LIMIT 1;'
})
const data = await rows.json().then((r: any) => r.data[0])

expect(data).toMatchObject({
timestamp: expect.stringMatching(TIMESTAMP_REGEX),
domain: "mywebsite.localhost",
path: "/foo",
operating_system: "Other",
browser_family: "Other",
device: "Other",
domain: 'mywebsite.localhost',
path: '/foo',
operating_system: 'Other',
browser_family: 'Other',
device: 'Other'
})
})

test('valid URL with registered domain in Referer header is accepted', async () => {
const response = await fetch(PAGEVIEWS_ENDPOINT, {
method: "POST",
method: 'POST',
headers: {
"Referer": "http://foo.mywebsite.localhost/another/foo?bar=baz#qux"
Referer: 'http://foo.mywebsite.localhost/another/foo?bar=baz#qux'
}
})
expect(response.status).toBe(200)
Expand All @@ -97,33 +97,33 @@ test('valid URL with registered domain in Referer header is accepted', async ()
Bun.sleepSync(1000)

const client = createClient({
host: "http://clickhouse.localhost:8123",
username: "clickhouse",
password: "password",
database: "prisme",
host: 'http://clickhouse.localhost:8123',
username: 'clickhouse',
password: 'password',
database: 'prisme'
})

const rows = await client.query({
query: `SELECT * FROM prisme.events_pageviews ORDER BY timestamp DESC LIMIT 1;`
query: 'SELECT * FROM prisme.events_pageviews ORDER BY timestamp DESC LIMIT 1;'
})
const data = await rows.json().then((r: any) => r.data[0])

expect(data).toMatchObject({
timestamp: expect.stringMatching(TIMESTAMP_REGEX),
domain: "foo.mywebsite.localhost",
path: "/another/foo",
operating_system: "Other",
browser_family: "Other",
device: "Other",
domain: 'foo.mywebsite.localhost',
path: '/another/foo',
operating_system: 'Other',
browser_family: 'Other',
device: 'Other'
})
})

test('valid pageview with Windows + Chrome user agent', async () => {
const response = await fetch(PAGEVIEWS_ENDPOINT, {
method: "POST",
method: 'POST',
headers: {
"Referer": "http://foo.mywebsite.localhost/another/foo?bar=baz#qux",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.3"
Referer: 'http://foo.mywebsite.localhost/another/foo?bar=baz#qux',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.3'
}
})
expect(response.status).toBe(200)
Expand All @@ -132,23 +132,23 @@ test('valid pageview with Windows + Chrome user agent', async () => {
Bun.sleepSync(1000)

const client = createClient({
host: "http://clickhouse.localhost:8123",
username: "clickhouse",
password: "password",
database: "prisme",
host: 'http://clickhouse.localhost:8123',
username: 'clickhouse',
password: 'password',
database: 'prisme'
})

const rows = await client.query({
query: `SELECT * FROM prisme.events_pageviews ORDER BY timestamp DESC LIMIT 1;`
query: 'SELECT * FROM prisme.events_pageviews ORDER BY timestamp DESC LIMIT 1;'
})
const data = await rows.json().then((r: any) => r.data[0])

expect(data).toMatchObject({
timestamp: expect.stringMatching(TIMESTAMP_REGEX),
domain: "foo.mywebsite.localhost",
path: "/another/foo",
operating_system: "Windows",
browser_family: "Chrome",
device: "Other",
domain: 'foo.mywebsite.localhost',
path: '/another/foo',
operating_system: 'Windows',
browser_family: 'Chrome',
device: 'Other'
})
})

0 comments on commit ff59e74

Please sign in to comment.