NS-21: fix gdlint in test suites (load-once, line length, const name)
parent
791c7dad1b
commit
f09517af6a
|
|
@ -2,10 +2,12 @@
|
|||
# Full ray / viewport pick flow stays manual (see README).
|
||||
extends GdUnitTestSuite
|
||||
|
||||
const GroundPickScript: GDScript = load("res://scripts/ground_pick.gd")
|
||||
|
||||
|
||||
func test_collider_is_walkable_true_when_ancestor_in_walkable_group() -> void:
|
||||
var gp := Node3D.new()
|
||||
gp.set_script(load("res://scripts/ground_pick.gd"))
|
||||
gp.set_script(GroundPickScript)
|
||||
auto_free(gp)
|
||||
add_child(gp)
|
||||
var floor_root := StaticBody3D.new()
|
||||
|
|
@ -19,7 +21,7 @@ func test_collider_is_walkable_true_when_ancestor_in_walkable_group() -> void:
|
|||
|
||||
func test_collider_is_walkable_false_without_walkable_group() -> void:
|
||||
var gp := Node3D.new()
|
||||
gp.set_script(load("res://scripts/ground_pick.gd"))
|
||||
gp.set_script(GroundPickScript)
|
||||
auto_free(gp)
|
||||
add_child(gp)
|
||||
var body := StaticBody3D.new()
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
extends GdUnitTestSuite
|
||||
|
||||
const _Double := preload("res://test/position_authority_test_double.gd")
|
||||
const PositionAuthorityTestDouble := preload("res://test/position_authority_test_double.gd")
|
||||
|
||||
|
||||
## In-process transport (not `HTTPRequest` subclass — Godot 4 will not call script `request()` on native subclasses).
|
||||
class MockHttpTransport extends Node:
|
||||
signal request_completed(result: int, response_code: int, headers: PackedStringArray, body: PackedByteArray)
|
||||
# In-process transport: not an HTTPRequest subclass (Godot 4 won't call script request() on those).
|
||||
class MockHttpTransport:
|
||||
extends Node
|
||||
signal request_completed(
|
||||
result: int, response_code: int, headers: PackedStringArray, body: PackedByteArray
|
||||
)
|
||||
var _queue: Array[Dictionary] = []
|
||||
|
||||
func enqueue(result: int, code: int, body: String) -> void:
|
||||
|
|
@ -20,13 +23,17 @@ class MockHttpTransport extends Node:
|
|||
if _queue.is_empty():
|
||||
return ERR_UNAVAILABLE
|
||||
var r: Dictionary = _queue.pop_front()
|
||||
request_completed.emit(r["result"], r["code"], PackedStringArray(), str(r["body"]).to_utf8_buffer())
|
||||
var body_bytes: PackedByteArray = str(r["body"]).to_utf8_buffer()
|
||||
request_completed.emit(r["result"], r["code"], PackedStringArray(), body_bytes)
|
||||
return OK
|
||||
|
||||
|
||||
## Holds `_busy` without completing (never emits `request_completed`).
|
||||
class HangingHttpTransport extends Node:
|
||||
signal request_completed(result: int, response_code: int, headers: PackedStringArray, body: PackedByteArray)
|
||||
# Holds _busy without completing (never emits request_completed).
|
||||
class HangingHttpTransport:
|
||||
extends Node
|
||||
signal request_completed(
|
||||
result: int, response_code: int, headers: PackedStringArray, body: PackedByteArray
|
||||
)
|
||||
var request_count: int = 0
|
||||
|
||||
func request(
|
||||
|
|
@ -40,7 +47,7 @@ class HangingHttpTransport extends Node:
|
|||
|
||||
|
||||
func _make_client(mock: Node) -> Node:
|
||||
var c: Node = _Double.new()
|
||||
var c: Node = PositionAuthorityTestDouble.new()
|
||||
c.set("injected_http", mock)
|
||||
auto_free(mock)
|
||||
auto_free(c)
|
||||
|
|
@ -89,9 +96,7 @@ func test_move_post_400_without_reason_emits_unknown() -> void:
|
|||
func test_move_post_200_then_verify_get_emits_nav_goal() -> void:
|
||||
var mock := MockHttpTransport.new()
|
||||
mock.enqueue(HTTPRequest.RESULT_SUCCESS, 200, "")
|
||||
mock.enqueue(
|
||||
HTTPRequest.RESULT_SUCCESS, 200, '{"position":{"x":2,"y":0.5,"z":-1}}'
|
||||
)
|
||||
mock.enqueue(HTTPRequest.RESULT_SUCCESS, 200, '{"position":{"x":2,"y":0.5,"z":-1}}')
|
||||
var c := _make_client(mock)
|
||||
monitor_signals(c)
|
||||
c.submit_move_target(Vector3(9.0, 0.0, 9.0))
|
||||
|
|
|
|||
Loading…
Reference in New Issue