~mil/sxmo-devel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
4 3

[PATCH sxmo-utils v3] test youtube search

Details
Message ID
<20220506030510.24660-1-anjan@momi.ca>
DKIM signature
pass
Download raw message
Patch: +17 -0
---
 .build.yml                                   |  4 ++++
 spec/scripts/appscripts/sxmo_youtube_spec.sh | 13 +++++++++++++
 2 files changed, 17 insertions(+)
 create mode 100644 spec/scripts/appscripts/sxmo_youtube_spec.sh

diff --git a/.build.yml b/.build.yml
index 10245f3..31ba79a 100644
--- a/.build.yml
+++ b/.build.yml
@@ -3,6 +3,8 @@ packages:
  - shellcheck
  - editorconfig-checker
  - shellspec
  - codemadness-frontends
  - gawk
sources:
  - https://git.sr.ht/~mil/sxmo-utils
tasks:
@@ -11,6 +13,8 @@ tasks:
      shellcheck -x scripts/*/*.sh
  - shellspec: |
      cd sxmo-utils
      export PATH="$PATH:./scripts/core"
      chmod +x scripts/core/sxmo_common.sh
      shellspec
  - editorconfig-check: |
      cd sxmo-utils
diff --git a/spec/scripts/appscripts/sxmo_youtube_spec.sh b/spec/scripts/appscripts/sxmo_youtube_spec.sh
new file mode 100644
index 0000000..29ea68e
--- /dev/null
+++ b/spec/scripts/appscripts/sxmo_youtube_spec.sh
@@ -0,0 +1,13 @@
# shellcheck disable=SC2155
# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2022 Sxmo Contributors
export PATH="$PATH:$(pwd)/scripts/appscripts"

Describe 'sxmo_youtube.sh'
	It 'search for youtube videos'
		When call sh scripts/appscripts/sxmo_youtube.sh youtubesearch "big buck bunny"
		The status should be success
		The line 1 of stdout should equal "10:35 Big Buck Bunny 60fps 4K - Official Blender Foundation Short Film https://www.youtube.com/embed/aqz-KE-bpKQ"
	End

End
-- 
2.34.2

[sxmo-utils/patches/.build.yml] build failed

builds.sr.ht <builds@sr.ht>
Details
Message ID
<CJSCHNDZODZH.Q0UKPKBF25ZA@cirno>
In-Reply-To
<20220506030510.24660-1-anjan@momi.ca> (view parent)
DKIM signature
missing
Download raw message
sxmo-utils/patches/.build.yml: FAILED in 24s

[test youtube search][0] v3 from [Anjandev Momi][1]

[0]: https://lists.sr.ht/~mil/sxmo-devel/patches/32025
[1]: anjan@momi.ca

✗ #752197 FAILED sxmo-utils/patches/.build.yml https://builds.sr.ht/~mil/job/752197
Details
Message ID
<878rrfe4je.fsf@momi.ca>
In-Reply-To
<20220506030510.24660-1-anjan@momi.ca> (view parent)
DKIM signature
pass
Download raw message
Not sure why this isnt working here but works here:

https://builds.sr.ht/~anjan/job/752203
--
w:] www.momi.ca
pgp:] https://momi.ca/publickey.txt
Details
Message ID
<30OWHF7HIUAK1.2NSSVHACZBU1Z@yellow-orcess.my.domain>
In-Reply-To
<20220506030510.24660-1-anjan@momi.ca> (view parent)
DKIM signature
pass
Download raw message
> diff --git a/spec/scripts/appscripts/sxmo_youtube_spec.sh b/spec/scripts/appscripts/sxmo_youtube_spec.sh
> new file mode 100644
> index 0000000..29ea68e
> --- /dev/null
> +++ b/spec/scripts/appscripts/sxmo_youtube_spec.sh
> @@ -0,0 +1,13 @@
> +# shellcheck disable=SC2155
> +# SPDX-License-Identifier: AGPL-3.0-only
> +# Copyright 2022 Sxmo Contributors
> +export PATH="$PATH:$(pwd)/scripts/appscripts"
> +
> +Describe 'sxmo_youtube.sh'
> +	It 'search for youtube videos'
> +		When call sh scripts/appscripts/sxmo_youtube.sh youtubesearch "big buck bunny"
> +		The status should be success
> +		The line 1 of stdout should equal "10:35 Big Buck Bunny 60fps 4K - Official Blender Foundation Short Film https://www.youtube.com/embed/aqz-KE-bpKQ"
> +	End
> +
> +End

I think this isnt safe to rely on a youtube query on our tests. We
should rather mock the client we use.
Details
Message ID
<23G0VBWYA5K3W.2XMYJ7WXRXA1H@yellow-orcess.my.domain>
In-Reply-To
<30OWHF7HIUAK1.2NSSVHACZBU1Z@yellow-orcess.my.domain> (view parent)
DKIM signature
pass
Download raw message
What I mean by "mock the client" is to define a youtube-cli script or
function that will stdout something like youtube-cli would do when you
call it with the args we use in sxmo_youtube.sh. Thats "mocking", or
stubing.

We can then see if sxmo_youtube.sh youtubesearch "big buck bunny"
returns the output we expect it to return without actually needing
network access, or knowing what are youtube results.

In the end, the only thing we care to test is if the combinaison of grep
+ awk + tr + give the expected results. That doesnt looks that worth it
to me.
Reply to thread Export thread (mbox)