This is an automated email from the ASF dual-hosted git repository.

msciabarra pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/openserverless-cli.git


The following commit(s) were added to refs/heads/main by this push:
     new c45dfd2  fixed update test
c45dfd2 is described below

commit c45dfd2484d1b05a21c50f4d043fedede22da67c
Author: Michele Sciabarra <[email protected]>
AuthorDate: Sat Jul 27 13:47:47 2024 +0200

    fixed update test
---
 .gitmodules                                |  7 ++++
 Taskfile.yml                               |  7 +++-
 cli.code-workspace                         | 10 +++++-
 main.go                                    | 16 ++++------
 prepare.go                                 |  4 +--
 tasktests/Taskfile.yml                     | 51 ++++++++++++++++++++++++++++++
 tasktests/olaris                           |  1 +
 tests/update.bats => tasktests/prereq.bats | 35 +++-----------------
 tests/update.bats                          |  6 ++--
 version.txt                                |  2 +-
 10 files changed, 92 insertions(+), 47 deletions(-)

diff --git a/.gitmodules b/.gitmodules
index 68ca29d..4797cf2 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -21,9 +21,16 @@
 [submodule "tools/wsk"]
        path = _patches/wsk
        url = https://github.com/sciabarracom/openwhisk-cli
+       branch = openserverless
 [submodule "tools/wskdeploy"]
        path = _patches/wskdeploy
        url = https://github.com/sciabarracom/openwhisk-wskdeploy
+       branch = openserverless
 [submodule "_patches/sh"]
        path = _patches/sh
        url = https://github.com/sciabarracom/sh
+       branch = openservlerless
+[submodule "tasktests/olaris"]
+       path = tasktests/olaris
+       url = https://github.com/apache/openserverless-task
+       branch = 0.1.0-testing
diff --git a/Taskfile.yml b/Taskfile.yml
index 233cbd1..83cbfe5 100644
--- a/Taskfile.yml
+++ b/Taskfile.yml
@@ -39,7 +39,6 @@ tasks:
     - git add version.txt branch.txt
     - git tag
 
-
   rebuild:
     - rm -f ops
     - task: build
@@ -58,10 +57,16 @@ tasks:
       - ops
 
   debug:
+    description: rebuild in debug mode
     cmds:
       - task: build
         vars:
           DEBUG: "-gcflags '-l -N'"
+
+  debugging:
+    description: build in debug mode and launch with the debugger - pass args 
wuth `task debugging -- <args>`
+    cmds:
+      - task: debug
       - dlv exec ./ops -- {{.CLI_ARGS}}
 
   install:
diff --git a/cli.code-workspace b/cli.code-workspace
index 68e91f6..9eb60b8 100644
--- a/cli.code-workspace
+++ b/cli.code-workspace
@@ -1,8 +1,16 @@
 {
   "folders": [
     {
-      "name": "ops",
+      "name": "cli",
       "path": "."
+    },
+    {
+      "name": "testing",
+      "path": "../testing"
+    },
+    {
+      "name": "olaris",
+      "path": "../testing/test-ops/olaris"
     }
   ],
   "settings": {
diff --git a/main.go b/main.go
index ea82eb2..5aa4f59 100644
--- a/main.go
+++ b/main.go
@@ -132,15 +132,13 @@ func Main() {
        // Check if olaris exists. If not, run `-update` to auto setup
        olarisDir := joinpath(joinpath(nuvHome, getNuvBranch()), "olaris")
        if !isDir(olarisDir) {
-               if !(len(os.Args) == 2 && os.Args[1] == "-update") {
-                       log.Println("Welcome to nuv! Setting up...")
-                       dir, err := pullTasks(true, true)
-                       if err != nil {
-                               log.Fatalf("error: %v", err)
-                       }
-                       if err := setNuvOlarisHash(dir); err != nil {
-                               warn("unable to set NUV_OLARIS...", err.Error())
-                       }
+               log.Println("Welcome to nuv! Setting up...")
+               dir, err := pullTasks(true, true)
+               if err != nil {
+                       log.Fatalf("error: %v", err)
+               }
+               if err := setNuvOlarisHash(dir); err != nil {
+                       warn("unable to set NUV_OLARIS...", err.Error())
                }
        }
 
diff --git a/prepare.go b/prepare.go
index 21e7424..c5ff668 100644
--- a/prepare.go
+++ b/prepare.go
@@ -122,14 +122,14 @@ func pullTasks(force, silent bool) (string, error) {
        }
 
        // check if the version is up to date
-       nuvVersion, err := semver.NewVersion(NuvVersion)
+       nuvVersion, err := semver.NewVersion(NuvVersion[1:])
        if err != nil {
                // in development mode, we don't have a valid semver version
                warn("Unable to validate nuv version", NuvVersion, ":", err)
                return localDir, nil
        }
 
-       nuvRootVersion, err := semver.NewVersion(nuvRoot.Version)
+       nuvRootVersion, err := semver.NewVersion(nuvRoot.Version[1:])
        if err != nil {
                warn("Unable to validate nuvroot.json version", 
nuvRoot.Version, ":", err)
                return localDir, nil
diff --git a/tasktests/Taskfile.yml b/tasktests/Taskfile.yml
new file mode 100644
index 0000000..f395392
--- /dev/null
+++ b/tasktests/Taskfile.yml
@@ -0,0 +1,51 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+version: "3"
+
+vars:
+  BRANCH: "0.1.0-testing"
+  BASEVER: "0.1.0-testing"
+  VERSION:
+    sh: git describe --tags --abbrev=0 2>/dev/null || git rev-parse --short 
HEAD
+  DEBUG: ""
+
+tasks:
+
+  default: task -l
+  setup: { silent:true }
+
+  bats:
+    dir: tests
+    cmds:
+    - git clone https://github.com/bats-core/bats-core bats
+    - git clone https://github.com/bats-core/bats-support 
test_helper/bats-support
+    - git clone https://github.com/bats-core/bats-assert 
test_helper/bats-assert
+    status:
+    - test -d bats
+
+  test:
+    desc: integration tests for nuv (T=<test-name> without .bats, empty all)
+    dir: tests
+    cmds:
+      - task: bats
+      - |
+        if test -z "{{.T}}"
+        then bats/bin/bats .
+        else bats/bin/bats {{.T}}.bats
+        fi
+
diff --git a/tasktests/olaris b/tasktests/olaris
new file mode 160000
index 0000000..8821aa3
--- /dev/null
+++ b/tasktests/olaris
@@ -0,0 +1 @@
+Subproject commit 8821aa3833801ceffa6e240a2ddf8c4523300d0c
diff --git a/tests/update.bats b/tasktests/prereq.bats
similarity index 50%
copy from tests/update.bats
copy to tasktests/prereq.bats
index 5301f9a..eae06c1 100644
--- a/tests/update.bats
+++ b/tasktests/prereq.bats
@@ -19,38 +19,13 @@ setup() {
     load 'test_helper/bats-support/load'
     load 'test_helper/bats-assert/load'
     export NO_COLOR=1
+    mkdir linux
+    cd linux
 }
 
-@test "nuv -update" {
-    run rm -rf ~/.nuv
-    run nuv -update
-    assert_line "Nuvfiles downloaded successfully"
+@test "7z" {
+    run task -t ../olaris/prereq.yaml 7z
     assert_success
+    #assert_line "Usage:"
 }
 
-@test "nuv -update with old version warns" {
-    NUV_VERSION=0.0.0 run nuv -update
-    assert_line --partial "Your nuv version (0.2.0) is older than the required 
version in nuvroot.json"
-    assert_line "Attempting to update nuv..."
-    assert_success
-}
-
-@test "nuv -update with bad version" {
-    NUV_VERSION=notsemver run nuv -update
-    assert_line "Unable to validate nuv version notsemver : Invalid Semantic 
Version"
-    assert_success
-}
-
-@test "nuv -update with newer version" {
-    NUV_VERSION=10.2.3 run nuv -update
-    assert_line "Tasks are already up to date!"
-    assert_success
-}
-
-@test "nuv -update on branch" {
-    run rm -rf ~/.nuv
-    export NUV_BRANCH=0.1.0-testing
-    run nuv -update
-    assert_line "Nuvfiles downloaded successfully"
-    assert_success
-}
diff --git a/tests/update.bats b/tests/update.bats
index 5301f9a..b4e76fb 100644
--- a/tests/update.bats
+++ b/tests/update.bats
@@ -29,8 +29,8 @@ setup() {
 }
 
 @test "nuv -update with old version warns" {
-    NUV_VERSION=0.0.0 run nuv -update
-    assert_line --partial "Your nuv version (0.2.0) is older than the required 
version in nuvroot.json"
+    NUV_VERSION=v0.0.0 run nuv -update
+    assert_line --partial "Your nuv version (0.0.0) is older than the required 
version in nuvroot.json"
     assert_line "Attempting to update nuv..."
     assert_success
 }
@@ -42,7 +42,7 @@ setup() {
 }
 
 @test "nuv -update with newer version" {
-    NUV_VERSION=10.2.3 run nuv -update
+    NUV_VERSION=v10.1.2 run nuv -update
     assert_line "Tasks are already up to date!"
     assert_success
 }
diff --git a/version.txt b/version.txt
index 4611165..7bdb89f 100644
--- a/version.txt
+++ b/version.txt
@@ -1 +1 @@
-0.1.0-testing.2407261504
+0.1.0-testing.2407270956

Reply via email to