From 348ee69aaa59976259fe8f0b727a1719bc7663d9 Mon Sep 17 00:00:00 2001 From: Josh Spicer Date: Wed, 16 Nov 2022 22:18:29 +0000 Subject: follow symlinks when chowning and add practical dotnet test --- test/dotnet/assert_run_project.sh | 8 +++++++ test/dotnet/example_project/.gitignore | 2 ++ test/dotnet/example_project/Movie.cs | 8 +++++++ test/dotnet/example_project/Program.cs | 27 ++++++++++++++++++++++ test/dotnet/example_project/example_project.csproj | 14 +++++++++++ test/dotnet/install_additional_dotnet.sh | 2 ++ test/dotnet/install_dotnet_3.sh | 2 ++ test/dotnet/install_dotnet_6_focal.sh | 2 ++ test/dotnet/install_dotnet_7_bullseye.sh | 2 ++ test/dotnet/install_dotnet_7_jammy.sh | 2 ++ test/dotnet/install_dotnet_latest.sh | 2 ++ test/dotnet/install_dotnet_lts.sh | 2 ++ test/dotnet/install_non_root_remoteUser.sh | 13 +++++++++++ test/dotnet/install_wo_apt.sh | 2 ++ test/dotnet/scenarios.json | 9 ++++++++ test/dotnet/test.sh | 2 ++ 16 files changed, 99 insertions(+) create mode 100644 test/dotnet/assert_run_project.sh create mode 100644 test/dotnet/example_project/.gitignore create mode 100644 test/dotnet/example_project/Movie.cs create mode 100644 test/dotnet/example_project/Program.cs create mode 100644 test/dotnet/example_project/example_project.csproj create mode 100644 test/dotnet/install_non_root_remoteUser.sh (limited to 'test/dotnet') diff --git a/test/dotnet/assert_run_project.sh b/test/dotnet/assert_run_project.sh new file mode 100644 index 0000000..872d068 --- /dev/null +++ b/test/dotnet/assert_run_project.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +set -e + +source dev-container-features-test-lib + +cd example_project +check "dotnet run" bash -c "dotnet run | grep 'Inception'" \ No newline at end of file diff --git a/test/dotnet/example_project/.gitignore b/test/dotnet/example_project/.gitignore new file mode 100644 index 0000000..8d4a6c0 --- /dev/null +++ b/test/dotnet/example_project/.gitignore @@ -0,0 +1,2 @@ +bin +obj \ No newline at end of file diff --git a/test/dotnet/example_project/Movie.cs b/test/dotnet/example_project/Movie.cs new file mode 100644 index 0000000..9d549ef --- /dev/null +++ b/test/dotnet/example_project/Movie.cs @@ -0,0 +1,8 @@ +// See https://aka.ms/new-console-template for more information + +internal class Movie +{ + public string Name { get; set; } = "Default Name"; + public DateTime ReleaseDate { get; set; } + public List Genres { get; set; } = new List(); +} diff --git a/test/dotnet/example_project/Program.cs b/test/dotnet/example_project/Program.cs new file mode 100644 index 0000000..7beb65f --- /dev/null +++ b/test/dotnet/example_project/Program.cs @@ -0,0 +1,27 @@ +// See https://aka.ms/new-console-template for more information + +using Newtonsoft.Json; + +Console.WriteLine("Hello, World!"); + +string json = @"{ + 'Name': 'Inception', + 'ReleaseDate': '2010-07-08T00:00:00', + 'Genres': [ + 'Action', + 'Thriller' + ] +}"; + +Movie? m = JsonConvert.DeserializeObject(json); + +if (m == default) +{ + Console.WriteLine("Decoding failed!"); +} +else +{ + Console.WriteLine($"Name: {m.Name}"); + Console.WriteLine($"Release Date: {m.ReleaseDate}"); + Console.WriteLine($"Genres: {string.Join(", ", m.Genres)}"); +} diff --git a/test/dotnet/example_project/example_project.csproj b/test/dotnet/example_project/example_project.csproj new file mode 100644 index 0000000..6132c9e --- /dev/null +++ b/test/dotnet/example_project/example_project.csproj @@ -0,0 +1,14 @@ + + + + Exe + net7.0 + enable + enable + + + + + + + diff --git a/test/dotnet/install_additional_dotnet.sh b/test/dotnet/install_additional_dotnet.sh index e69c7dc..b077462 100644 --- a/test/dotnet/install_additional_dotnet.sh +++ b/test/dotnet/install_additional_dotnet.sh @@ -13,5 +13,7 @@ check "dotnet version 3.1.420 installed" bash -c "ls -l /usr/local/dotnet | gre check "current link dotnet" /usr/local/dotnet/current/dotnet --info check "current link sdk" ls -l /usr/local/dotnet/current/sdk +./assert_run_project.sh + # Report result reportResults diff --git a/test/dotnet/install_dotnet_3.sh b/test/dotnet/install_dotnet_3.sh index 51d871b..aed11f5 100644 --- a/test/dotnet/install_dotnet_3.sh +++ b/test/dotnet/install_dotnet_3.sh @@ -13,5 +13,7 @@ check "dotnet version 3 installed" bash -c "ls -l /usr/share/dotnet/sdk | grep check "current link dotnet" /usr/local/dotnet/current/dotnet --info check "current link sdk" ls -l /usr/local/dotnet/current/sdk +./assert_run_project.sh + # Report result reportResults diff --git a/test/dotnet/install_dotnet_6_focal.sh b/test/dotnet/install_dotnet_6_focal.sh index 758f040..2b97e75 100644 --- a/test/dotnet/install_dotnet_6_focal.sh +++ b/test/dotnet/install_dotnet_6_focal.sh @@ -13,5 +13,7 @@ check "dotnet version 6 installed" bash -c "ls -l /usr/share/dotnet/sdk | grep check "current link dotnet" /usr/local/dotnet/current/dotnet --info check "current link sdk" ls -l /usr/local/dotnet/current/sdk +./assert_run_project.sh + # Report result reportResults diff --git a/test/dotnet/install_dotnet_7_bullseye.sh b/test/dotnet/install_dotnet_7_bullseye.sh index 2c015fc..6e78d7a 100644 --- a/test/dotnet/install_dotnet_7_bullseye.sh +++ b/test/dotnet/install_dotnet_7_bullseye.sh @@ -13,5 +13,7 @@ check "dotnet version 7 installed" bash -c "ls -l /usr/share/dotnet/sdk | grep check "current link dotnet" /usr/local/dotnet/current/dotnet --info check "current link sdk" ls -l /usr/local/dotnet/current/sdk +./assert_run_project.sh + # Report result reportResults diff --git a/test/dotnet/install_dotnet_7_jammy.sh b/test/dotnet/install_dotnet_7_jammy.sh index 2c015fc..6e78d7a 100644 --- a/test/dotnet/install_dotnet_7_jammy.sh +++ b/test/dotnet/install_dotnet_7_jammy.sh @@ -13,5 +13,7 @@ check "dotnet version 7 installed" bash -c "ls -l /usr/share/dotnet/sdk | grep check "current link dotnet" /usr/local/dotnet/current/dotnet --info check "current link sdk" ls -l /usr/local/dotnet/current/sdk +./assert_run_project.sh + # Report result reportResults diff --git a/test/dotnet/install_dotnet_latest.sh b/test/dotnet/install_dotnet_latest.sh index 2c015fc..6e78d7a 100644 --- a/test/dotnet/install_dotnet_latest.sh +++ b/test/dotnet/install_dotnet_latest.sh @@ -13,5 +13,7 @@ check "dotnet version 7 installed" bash -c "ls -l /usr/share/dotnet/sdk | grep check "current link dotnet" /usr/local/dotnet/current/dotnet --info check "current link sdk" ls -l /usr/local/dotnet/current/sdk +./assert_run_project.sh + # Report result reportResults diff --git a/test/dotnet/install_dotnet_lts.sh b/test/dotnet/install_dotnet_lts.sh index 758f040..2b97e75 100644 --- a/test/dotnet/install_dotnet_lts.sh +++ b/test/dotnet/install_dotnet_lts.sh @@ -13,5 +13,7 @@ check "dotnet version 6 installed" bash -c "ls -l /usr/share/dotnet/sdk | grep check "current link dotnet" /usr/local/dotnet/current/dotnet --info check "current link sdk" ls -l /usr/local/dotnet/current/sdk +./assert_run_project.sh + # Report result reportResults diff --git a/test/dotnet/install_non_root_remoteUser.sh b/test/dotnet/install_non_root_remoteUser.sh new file mode 100644 index 0000000..e9680cb --- /dev/null +++ b/test/dotnet/install_non_root_remoteUser.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +check "ensure i am user codespace" bash -c "whoami | grep 'codespace'" + +./install_dotnet_7_jammy.sh + +# Report result +reportResults diff --git a/test/dotnet/install_wo_apt.sh b/test/dotnet/install_wo_apt.sh index a1745c5..6a8b9ce 100644 --- a/test/dotnet/install_wo_apt.sh +++ b/test/dotnet/install_wo_apt.sh @@ -13,5 +13,7 @@ check "dotnet version 7 installed" bash -c "ls -l /usr/local/dotnet | grep '7\. check "current link dotnet" /usr/local/dotnet/current/dotnet --info check "current link sdk" ls -l /usr/local/dotnet/current/sdk +./assert_run_project.sh + # Report result reportResults diff --git a/test/dotnet/scenarios.json b/test/dotnet/scenarios.json index 37f83d5..1b88819 100644 --- a/test/dotnet/scenarios.json +++ b/test/dotnet/scenarios.json @@ -72,5 +72,14 @@ "installUsingApt": false } } + }, + "install_non_root_remoteUser": { + "image": "mcr.microsoft.com/devcontainers/universal:2", + "remoteUser": "codespace", + "features": { + "dotnet": { + "version": "7" + } + } } } \ No newline at end of file diff --git a/test/dotnet/test.sh b/test/dotnet/test.sh index 7eb0cf6..3befeec 100755 --- a/test/dotnet/test.sh +++ b/test/dotnet/test.sh @@ -17,5 +17,7 @@ check "some major version of dotnet 7 is installed" bash -c "dotnet --version | check "current link dotnet" /usr/local/dotnet/current/dotnet --info check "current link sdk" ls -l /usr/local/dotnet/current/sdk +./assert_run_project.sh + # Report result reportResults \ No newline at end of file -- cgit v1.2.3