~singpolyma/sgx-jmp

ref: 045da39f25b74034e7bba44cb5f1db48a935ba84 sgx-jmp/test/test_backend_sgx.rb -rw-r--r-- 1.3 KiB
045da39fStephen Paul Weber Hotfix: arguments in wrong order 1 year, 1 month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# frozen_string_literal: true

require "test_helper"
require "backend_sgx"

BackendSgx::IQ_MANAGER = Minitest::Mock.new

class BackendSgxTest < Minitest::Test
	def setup
		@sgx = BackendSgx.new("test")
	end

	def test_registered
		BackendSgx::IQ_MANAGER.expect(
			:write,
			EMPromise.resolve(IBR.new.tap { |ibr| ibr.registered = true }),
			[Matching.new do |ibr|
				assert_equal :get, ibr.type
				assert_equal "customer_test@component", ibr.from.to_s
			end]
		)
		assert @sgx.registered?.sync
	end
	em :test_registered

	def test_registered_not_registered
		BackendSgx::IQ_MANAGER.expect(
			:write,
			EMPromise.resolve(IBR.new.tap { |ibr| ibr.registered = false }),
			[Matching.new do |ibr|
				assert_equal :get, ibr.type
				assert_equal "customer_test@component", ibr.from.to_s
			end]
		)
		refute @sgx.registered?.sync
	end
	em :test_registered_not_registered

	def test_register!
		BackendSgx::IQ_MANAGER.expect(
			:write,
			EMPromise.resolve(OpenStruct.new(error?: false)),
			[Matching.new do |ibr|
				assert_equal "customer_test@component", ibr.from.to_s
				assert_equal "test_bw_account", ibr.nick
				assert_equal "test_bw_user", ibr.username
				assert_equal "test_bw_password", ibr.password
				assert_equal "+15555550000", ibr.phone
			end]
		)
		@sgx.register!("+15555550000")
		BackendSgx::IQ_MANAGER.verify
	end
end