@@ -14,6 +14,133 @@ teardown() {
14
14
standard_teardown
15
15
}
16
16
17
+ @test " extension-defined project template" {
18
+ start_webserver --directory www
19
+ EXTENSION_URL=" http://localhost:$E2E_WEB_SERVER_PORT /arbitrary/extension.json"
20
+ mkdir -p www/arbitrary/downloads www/arbitrary/project_templates/a-template
21
+
22
+ cat > www/arbitrary/extension.json << EOF
23
+ {
24
+ "name": "an-extension",
25
+ "version": "0.1.0",
26
+ "homepage": "https://github.com/dfinity/dfx-extensions",
27
+ "authors": "DFINITY",
28
+ "summary": "Test extension for e2e purposes.",
29
+ "categories": [],
30
+ "keywords": [],
31
+ "project_templates": {
32
+ "rust-by-extension": {
33
+ "category": "backend",
34
+ "display": "rust by extension",
35
+ "requirements": [],
36
+ "post_create": "cargo update",
37
+ "port_create_failure_warning": "You will need to run it yourself (or a similar command like 'cargo vendor'), because 'dfx build' will use the --locked flag with Cargo."
38
+ }
39
+ },
40
+ "download_url_template": "http://localhost:$E2E_WEB_SERVER_PORT /arbitrary/downloads/{{tag}}.{{archive-format}}"
41
+ }
42
+ EOF
43
+
44
+ cat > www/arbitrary/dependencies.json << EOF
45
+ {
46
+ "0.1.0": {
47
+ "dfx": {
48
+ "version": ">=0.8.0"
49
+ }
50
+ }
51
+ }
52
+ EOF
53
+
54
+ cp -R " ${BATS_TEST_DIRNAME} /../../src/dfx/assets/project_templates/rust" www/arbitrary/project_templates/rust-by-extension
55
+
56
+ ARCHIVE_BASENAME=" an-extension-v0.1.0"
57
+
58
+ mkdir " $ARCHIVE_BASENAME "
59
+ cp www/arbitrary/extension.json " $ARCHIVE_BASENAME "
60
+ cp -R www/arbitrary/project_templates " $ARCHIVE_BASENAME "
61
+ tar -czf " $ARCHIVE_BASENAME " .tar.gz " $ARCHIVE_BASENAME "
62
+ rm -rf " $ARCHIVE_BASENAME "
63
+
64
+ mv " $ARCHIVE_BASENAME " .tar.gz www/arbitrary/downloads/
65
+
66
+ assert_command dfx extension install " $EXTENSION_URL "
67
+
68
+ setup_rust
69
+
70
+ dfx new rbe --type rust-by-extension --no-frontend
71
+ cd rbe || exit
72
+
73
+ dfx_start
74
+ assert_command dfx deploy
75
+ assert_command dfx canister call rbe_backend greet ' ("Rust By Extension")'
76
+ assert_contains " Hello, Rust By Extension!"
77
+ }
78
+
79
+ @test " extension-defined project template replaces built-in type" {
80
+ start_webserver --directory www
81
+ EXTENSION_URL=" http://localhost:$E2E_WEB_SERVER_PORT /arbitrary/extension.json"
82
+ mkdir -p www/arbitrary/downloads www/arbitrary/project_templates/a-template
83
+
84
+ cat > www/arbitrary/extension.json << EOF
85
+ {
86
+ "name": "an-extension",
87
+ "version": "0.1.0",
88
+ "homepage": "https://github.com/dfinity/dfx-extensions",
89
+ "authors": "DFINITY",
90
+ "summary": "Test extension for e2e purposes.",
91
+ "categories": [],
92
+ "keywords": [],
93
+ "project_templates": {
94
+ "rust": {
95
+ "category": "backend",
96
+ "display": "rust by extension",
97
+ "requirements": [],
98
+ "post_create": "cargo update"
99
+ }
100
+ },
101
+ "download_url_template": "http://localhost:$E2E_WEB_SERVER_PORT /arbitrary/downloads/{{tag}}.{{archive-format}}"
102
+ }
103
+ EOF
104
+
105
+ cat > www/arbitrary/dependencies.json << EOF
106
+ {
107
+ "0.1.0": {
108
+ "dfx": {
109
+ "version": ">=0.8.0"
110
+ }
111
+ }
112
+ }
113
+ EOF
114
+
115
+ cp -R " ${BATS_TEST_DIRNAME} /../../src/dfx/assets/project_templates/rust" www/arbitrary/project_templates/rust
116
+ echo " just-proves-it-used-the-project-template" > www/arbitrary/project_templates/rust/proof.txt
117
+
118
+ ARCHIVE_BASENAME=" an-extension-v0.1.0"
119
+
120
+ mkdir " $ARCHIVE_BASENAME "
121
+ cp www/arbitrary/extension.json " $ARCHIVE_BASENAME "
122
+ cp -R www/arbitrary/project_templates " $ARCHIVE_BASENAME "
123
+ tar -czf " $ARCHIVE_BASENAME " .tar.gz " $ARCHIVE_BASENAME "
124
+ rm -rf " $ARCHIVE_BASENAME "
125
+
126
+ mv " $ARCHIVE_BASENAME " .tar.gz www/arbitrary/downloads/
127
+
128
+ assert_command dfx extension install " $EXTENSION_URL "
129
+
130
+ setup_rust
131
+
132
+ dfx new rbe --type rust --no-frontend
133
+ assert_command cat rbe/proof.txt
134
+ assert_eq " just-proves-it-used-the-project-template"
135
+
136
+ cd rbe || exit
137
+
138
+ dfx_start
139
+ assert_command dfx deploy
140
+ assert_command dfx canister call rbe_backend greet ' ("Rust By Extension")'
141
+ assert_contains " Hello, Rust By Extension!"
142
+ }
143
+
17
144
@test " run an extension command with a canister type defined by another extension" {
18
145
install_shared_asset subnet_type/shared_network_settings/system
19
146
dfx_start_for_nns_install
0 commit comments