From 120d7fbe54bcebebf9fcacb6d63381a443d7220f Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Wed, 24 Mar 2021 10:54:40 +0100 Subject: [PATCH 1/3] Use `#[ink::test]` instead of `#[test]` --- templates/new/lib.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/templates/new/lib.rs b/templates/new/lib.rs index c81744f8..dea255cb 100644 --- a/templates/new/lib.rs +++ b/templates/new/lib.rs @@ -52,15 +52,18 @@ mod {{name}} { /// Imports all the definitions from the outer scope so we can use them here. use super::*; + /// Imports `ink_lang` so that we can use `#[ink::test]`. + use ink_lang as ink; + /// We test if the default constructor does its job. - #[test] + #[ink::test] fn default_works() { let {{name}} = {{camel_name}}::default(); assert_eq!({{name}}.get(), false); } /// We test a simple use case of our contract. - #[test] + #[ink::test] fn it_works() { let mut {{name}} = {{camel_name}}::new(false); assert_eq!({{name}}.get(), false); -- GitLab From fc24fdb84f1f104b758fb4a7bc52ded5175164b3 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Wed, 24 Mar 2021 16:07:29 +0100 Subject: [PATCH 2/3] Test new project template in CI --- .gitlab-ci.yml | 15 +++++++++++++++ templates/new/lib.rs | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4ea682d3..a83088cb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -81,6 +81,21 @@ test: script: - cargo test --verbose --workspace --all-features +test-new-project-template: + stage: test + <<: *docker-env + script: + - cargo run -- contract new new_project + - cd new_project + + # needed because otherwise: + # `error: current package believes it's in a workspace when it's not` + - echo "[workspace]" >> Cargo.toml + + - cargo check --verbose + - cargo test --verbose --all + - cargo fmt --verbose --all -- --check + #### stage: build (default features) build: diff --git a/templates/new/lib.rs b/templates/new/lib.rs index dea255cb..45c4c5ed 100644 --- a/templates/new/lib.rs +++ b/templates/new/lib.rs @@ -52,7 +52,7 @@ mod {{name}} { /// Imports all the definitions from the outer scope so we can use them here. use super::*; - /// Imports `ink_lang` so that we can use `#[ink::test]`. + /// Imports `ink_lang` so we can use `#[ink::test]`. use ink_lang as ink; /// We test if the default constructor does its job. -- GitLab From 4ff441e94f0fc1361f45cb1466d68a2c99329807 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Wed, 24 Mar 2021 17:15:16 +0100 Subject: [PATCH 3/3] Revert "Use `#[ink::test]` instead of `#[test]`" This reverts commit 120d7fbe54bcebebf9fcacb6d63381a443d7220f. --- templates/new/lib.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/templates/new/lib.rs b/templates/new/lib.rs index 45c4c5ed..c81744f8 100644 --- a/templates/new/lib.rs +++ b/templates/new/lib.rs @@ -52,18 +52,15 @@ mod {{name}} { /// Imports all the definitions from the outer scope so we can use them here. use super::*; - /// Imports `ink_lang` so we can use `#[ink::test]`. - use ink_lang as ink; - /// We test if the default constructor does its job. - #[ink::test] + #[test] fn default_works() { let {{name}} = {{camel_name}}::default(); assert_eq!({{name}}.get(), false); } /// We test a simple use case of our contract. - #[ink::test] + #[test] fn it_works() { let mut {{name}} = {{camel_name}}::new(false); assert_eq!({{name}}.get(), false); -- GitLab