File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 1+ # frozen_string_literal: true
2+
3+ require "test_helper"
4+ require "serverkit/resources/vscode_package"
5+
6+ class Serverkit ::Resources ::VscodePackageTest < Minitest ::Test
7+ ATTRIBUTES = { "name" => "test-package" }
8+ ATTRIBUTES_WITH_VERSION = { "name" => "test-package" , "version" => "1.2.3" }
9+
10+ def setup
11+ @resource = Serverkit ::Resources ::VscodePackage . new ( { } , ATTRIBUTES )
12+ @resource_with_version = Serverkit ::Resources ::VscodePackage . new ( { } , ATTRIBUTES_WITH_VERSION )
13+ end
14+
15+ def test_resource_instance
16+ assert_instance_of Serverkit ::Resources ::VscodePackage , @resource
17+ assert_instance_of Serverkit ::Resources ::VscodePackage , @resource_with_version
18+ end
19+
20+ def test_apply
21+ @resource . stub :run_command , -> ( cmd ) { cmd } do
22+ assert_equal ( "code --install-extension test-package" , @resource . apply )
23+ end
24+ @resource_with_version . stub :run_command , -> ( cmd ) { cmd } do
25+ assert_equal ( "code --install-extension test-package@1.2.3" , resource_with_version . apply )
26+ end
27+ end
28+
29+ def test_check
30+ @resource . stub :check_command , -> ( cmd ) { cmd } do
31+ assert_equal ( "code --list-extensions --show-versions | grep -E '^test-package@'" , @resource . check )
32+ end
33+ @resource_with_version . stub :check_command , -> ( cmd ) { cmd } do
34+ assert_equal ( "code --list-extensions --show-versions | grep -E '^test-package@1.2.3$'" , resource_with_version . check )
35+ end
36+ end
37+ end
You can’t perform that action at this time.
0 commit comments