Refactor tests
This commit is contained in:
		
							parent
							
								
									c1c46707ba
								
							
						
					
					
						commit
						d278cfa353
					
				| @ -8,6 +8,7 @@ defmodule Chronoscope.NTS.CertificateTest do | |||||||
| 
 | 
 | ||||||
|   setup :verify_on_exit! |   setup :verify_on_exit! | ||||||
| 
 | 
 | ||||||
|  |   describe "Chronoscope.NTS.Certificate.expiration_date()" do | ||||||
|     test "parses the expiration date of a certificate" do |     test "parses the expiration date of a certificate" do | ||||||
|       {:ok, expiration, _} = |       {:ok, expiration, _} = | ||||||
|         :secp256r1 |         :secp256r1 | ||||||
| @ -19,7 +20,9 @@ defmodule Chronoscope.NTS.CertificateTest do | |||||||
| 
 | 
 | ||||||
|       assert DateTime.diff(expiration, DateTime.utc_now(), :day) == 12 |       assert DateTime.diff(expiration, DateTime.utc_now(), :day) == 12 | ||||||
|     end |     end | ||||||
|  |   end | ||||||
| 
 | 
 | ||||||
|  |   describe "Chronoscope.NTS.Certificate.cert_time_to_iso8601()" do | ||||||
|     test "converts certificate datetime to iso8601" do |     test "converts certificate datetime to iso8601" do | ||||||
|       DateTimeMock |       DateTimeMock | ||||||
|       |> expect(:utc_now, fn -> ~U[2024-03-31 01:23:45Z] end) |       |> expect(:utc_now, fn -> ~U[2024-03-31 01:23:45Z] end) | ||||||
| @ -40,4 +43,5 @@ defmodule Chronoscope.NTS.CertificateTest do | |||||||
| 
 | 
 | ||||||
|       assert cert_time_to_iso8601("010326110000Z") == "3001-03-26T11:00:00Z" |       assert cert_time_to_iso8601("010326110000Z") == "3001-03-26T11:00:00Z" | ||||||
|     end |     end | ||||||
|  |   end | ||||||
| end | end | ||||||
|  | |||||||
| @ -3,8 +3,10 @@ defmodule Chronoscope.NTS.KeyEstablishmentRequestTest do | |||||||
| 
 | 
 | ||||||
|   import Chronoscope.NTS.KeyEstablishmentRequest |   import Chronoscope.NTS.KeyEstablishmentRequest | ||||||
| 
 | 
 | ||||||
|  |   describe "Chronoscope.NTS.KeyEstablishmentRequest.create()" do | ||||||
|     test "builds request" do |     test "builds request" do | ||||||
|       assert create() == |       assert create() == | ||||||
|                <<0x80, 0x01, 0x00, 0x02, 0x00, 0x00, 0x80, 0x04, 0x00, 0x04, 0x00, 0x1E, 0x00, 0x0F, 0x80, 0x00, 0x00, 0x00>> |                <<0x80, 0x01, 0x00, 0x02, 0x00, 0x00, 0x80, 0x04, 0x00, 0x04, 0x00, 0x1E, 0x00, 0x0F, 0x80, 0x00, 0x00, 0x00>> | ||||||
|     end |     end | ||||||
|  |   end | ||||||
| end | end | ||||||
|  | |||||||
| @ -3,6 +3,7 @@ defmodule Chronoscope.NTS.KeyEstablishmentResponseTest do | |||||||
| 
 | 
 | ||||||
|   import Chronoscope.NTS.KeyEstablishmentResponse |   import Chronoscope.NTS.KeyEstablishmentResponse | ||||||
| 
 | 
 | ||||||
|  |   describe "Chronoscope.NTS.KeyEstablishmentResponse.parse()" do | ||||||
|     test "handles empty response" do |     test "handles empty response" do | ||||||
|       assert parse([]) == {:ok, %{}} |       assert parse([]) == {:ok, %{}} | ||||||
|     end |     end | ||||||
| @ -141,4 +142,5 @@ defmodule Chronoscope.NTS.KeyEstablishmentResponseTest do | |||||||
|                   next_protocols: ["NTPv4"] |                   next_protocols: ["NTPv4"] | ||||||
|                 }} |                 }} | ||||||
|     end |     end | ||||||
|  |   end | ||||||
| end | end | ||||||
|  | |||||||
| @ -1,7 +1,8 @@ | |||||||
| defmodule ChronoscopeWeb.API.V1.HealthControllerTest do | defmodule ChronoscopeWeb.API.V1.HealthControllerTest do | ||||||
|   use ChronoscopeWeb.ConnCase, async: true |   use ChronoscopeWeb.ConnCase, async: true | ||||||
| 
 | 
 | ||||||
|   test "indicates health", %{conn: conn} do |   describe "GET /api/v1/health" do | ||||||
|  |     test "is healthy", %{conn: conn} do | ||||||
|       response = |       response = | ||||||
|         conn |         conn | ||||||
|         |> get(~p"/api/v1/health") |         |> get(~p"/api/v1/health") | ||||||
| @ -9,4 +10,5 @@ defmodule ChronoscopeWeb.API.V1.HealthControllerTest do | |||||||
| 
 | 
 | ||||||
|       assert %{"healthy" => true} == response |       assert %{"healthy" => true} == response | ||||||
|     end |     end | ||||||
|  |   end | ||||||
| end | end | ||||||
|  | |||||||
| @ -5,7 +5,7 @@ defmodule ChronoscopeWeb.API.V1.NTS.KeyEstablishmentControllerTest do | |||||||
| 
 | 
 | ||||||
|   setup :verify_on_exit! |   setup :verify_on_exit! | ||||||
| 
 | 
 | ||||||
|   describe "/api/v1/nts/key-establishment" do |   describe "GET /api/v1/nts/key-establishment" do | ||||||
|     test "requires a host name", %{conn: conn} do |     test "requires a host name", %{conn: conn} do | ||||||
|       response = |       response = | ||||||
|         conn |         conn | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user