Skip to content

Commit

Permalink
style: condense test call signatures and move module tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nashaddams committed Nov 1, 2024
1 parent b811712 commit c474824
Show file tree
Hide file tree
Showing 18 changed files with 199 additions and 263 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
uses: actions/checkout@v4
- name: Mount RabbitMQ config files
run: |
docker cp ./test/rabbitmq.conf rabbitmq:/etc/rabbitmq/rabbitmq.conf
docker cp ./test/conf/rabbitmq.conf rabbitmq:/etc/rabbitmq/rabbitmq.conf
docker cp ./test/cert/ca_certificate.pem rabbitmq:/etc/ssl/certs/rabbitmq/ca_certificate.pem
docker cp ./test/cert/server_certificate.pem rabbitmq:/etc/ssl/certs/rabbitmq/server_certificate.pem
docker cp ./test/cert/server_key.pem rabbitmq:/etc/ssl/certs/rabbitmq/server_key.pem
Expand All @@ -39,10 +39,10 @@ jobs:
- name: Check formatting
run: deno fmt --check
- name: Lint
run: deno lint src/ module_test/
run: deno lint src/ test/
- name: Unit tests
run: deno task test
- name: Wait for RabbitMQ
run: deno run --allow-net module_test/wait_for_server.ts
run: deno run --allow-net test/wait_for_server.ts
- name: Module tests
run: deno task test:mod
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ podman run -d --rm \
-p 15672:15672 \
-p 5671:5671 \
-p 5672:5672 \
-v ./test/rabbitmq.conf:/etc/rabbitmq/rabbitmq.conf \
-v ./test/conf/rabbitmq.conf:/etc/rabbitmq/rabbitmq.conf \
-v ./test/cert/ca_certificate.pem:/etc/ssl/certs/rabbitmq/ca_certificate.pem \
-v ./test/cert/server_certificate.pem:/etc/ssl/certs/rabbitmq/server_certificate.pem \
-v ./test/cert/server_key.pem:/etc/ssl/certs/rabbitmq/server_key.pem \
Expand Down
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"tasks": {
"cache": "deno install --lock deno.lock && deno install --entrypoint deps_dev.ts",
"test": "deno test src",
"test:mod": "deno test -A --unsafely-ignore-certificate-errors=127.0.0.1 module_test/",
"test:mod": "deno test -A --unsafely-ignore-certificate-errors=127.0.0.1 test/",
"codegen": "deno task codegen:codec && deno task codegen:types && deno task codegen:constants",
"codegen:codec": "deno run codegen/generate_codec.ts | deno fmt - > src/amqp_codec.ts",
"codegen:types": "deno run codegen/generate_types.ts | deno fmt - > src/amqp_types.ts",
Expand Down
59 changes: 0 additions & 59 deletions module_test/connect_test.ts

This file was deleted.

30 changes: 0 additions & 30 deletions module_test/frame_error_test.ts

This file was deleted.

228 changes: 95 additions & 133 deletions src/amqp_connect_options_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,154 +49,116 @@ const defaultParams: AmqpConnectParameters = {
vhost: "/",
};

Deno.test(
...testUrl("amqp://user:pass@localhost:5672", {
...defaultParams,
username: "user",
password: "pass",
}),
);
Deno.test(...testUrl("amqp://user:pass@localhost:5672", {
...defaultParams,
username: "user",
password: "pass",
}));

Deno.test(...testUrl("amqp://localhost", {
...defaultParams,
}));

Deno.test(...testUrl("amqps://localhost", {
...defaultParams,
port: 5671,
}));

Deno.test(...testUrl("amqps://localhost:123", {
...defaultParams,
port: 123,
}));

Deno.test(...testUrl("amqp://somehost.com:123", {
...defaultParams,
hostname: "somehost.com",
port: 123,
}));

Deno.test(...testUrl("amqp://user:pass@somehost.com:123", {
...defaultParams,
hostname: "somehost.com",
port: 123,
username: "user",
password: "pass",
}));

Deno.test(...testUrl("amqp://localhost/%2f", {
...defaultParams,
vhost: "/",
}));

Deno.test(
...testUrl("amqp://localhost", {
...defaultParams,
}),
);
Deno.test(...testUrl("amqp://localhost/%2fsomevhostwithslash", {
...defaultParams,
vhost: "/somevhostwithslash",
}));

Deno.test(
...testUrl("amqps://localhost", {
...defaultParams,
port: 5671,
}),
);
Deno.test(...testUrl("amqp://localhost/somevhost", {
...defaultParams,
vhost: "somevhost",
}));

Deno.test(
...testUrl("amqps://localhost:123", {
...defaultParams,
port: 123,
}),
);
Deno.test(...testUrl("amqp://localhost:123/somevhost", {
...defaultParams,
vhost: "somevhost",
port: 123,
}));

Deno.test(
...testUrl("amqp://somehost.com:123", {
...defaultParams,
hostname: "somehost.com",
port: 123,
}),
...testUrlError("badproto://localhost:123/somevhost", "Unsupported protocol"),
);

Deno.test(
...testUrl("amqp://user:pass@somehost.com:123", {
...defaultParams,
hostname: "somehost.com",
port: 123,
username: "user",
password: "pass",
}),
);
Deno.test(...testUrl("amqp://localhost?heartbeat=10", {
...defaultParams,
heartbeatInterval: 10,
}));

Deno.test(
...testUrl("amqp://localhost/%2f", {
...defaultParams,
vhost: "/",
}),
);
Deno.test(...testUrlError(
"amqp://localhost?heartbeat=abc",
"Invalid heartbeat parameter abc",
));

Deno.test(
...testUrl("amqp://localhost/%2fsomevhostwithslash", {
...defaultParams,
vhost: "/somevhostwithslash",
}),
);
Deno.test(...testUrl("amqp://localhost?frame_max=10", {
...defaultParams,
frameMax: 10,
}));

Deno.test(
...testUrl("amqp://localhost/somevhost", {
...defaultParams,
vhost: "somevhost",
}),
);
Deno.test(...testUrlError(
"amqp://localhost?frame_max=abc",
"Invalid frame_max parameter abc",
));

Deno.test(
...testUrl("amqp://localhost:123/somevhost", {
...defaultParams,
vhost: "somevhost",
port: 123,
}),
);
Deno.test(...testOpts(undefined, {
...defaultParams,
}));

Deno.test(
...testUrlError("badproto://localhost:123/somevhost", "Unsupported protocol"),
);

Deno.test(
...testUrl("amqp://localhost?heartbeat=10", {
Deno.test(...testOpts(
{},
{
...defaultParams,
heartbeatInterval: 10,
}),
);

Deno.test(
...testUrlError(
"amqp://localhost?heartbeat=abc",
"Invalid heartbeat parameter abc",
),
);
},
));

Deno.test(
...testUrl("amqp://localhost?frame_max=10", {
Deno.test(...testOpts(
{ hostname: "somehost.com" },
{
...defaultParams,
frameMax: 10,
}),
);

Deno.test(
...testUrlError(
"amqp://localhost?frame_max=abc",
"Invalid frame_max parameter abc",
),
);
hostname: "somehost.com",
},
));

Deno.test(
...testOpts(undefined, {
Deno.test(...testOpts(
{ port: 123 },
{
...defaultParams,
}),
);

Deno.test(
...testOpts(
{},
{
...defaultParams,
},
),
);

Deno.test(
...testOpts(
{ hostname: "somehost.com" },
{
...defaultParams,
hostname: "somehost.com",
},
),
);

Deno.test(
...testOpts(
{ port: 123 },
{
...defaultParams,
port: 123,
},
),
);
port: 123,
},
));

Deno.test(
...testOpts(
{ port: 123 },
{
...defaultParams,
port: 123,
},
),
);
Deno.test(...testOpts(
{ port: 123 },
{
...defaultParams,
port: 123,
},
));
Loading

0 comments on commit c474824

Please sign in to comment.