Skip to content

Update http snippets for restsharp 107+ - #321

Closed
llimllib wants to merge 5 commits into
Kong:masterfrom
llimllib:restsharp-107-plus
Closed

Update http snippets for restsharp 107+#321
llimllib wants to merge 5 commits into
Kong:masterfrom
llimllib:restsharp-107-plus

Conversation

@llimllib

@llimllibllimllib commented Jun 16, 2023

Copy link
Copy Markdown

a whack at fixing #312

To test this, I:

  • generated all new fixtures with OVERWRITE_EVERYTHING=true npm run test
  • generated a C# hello world project with dotnet new console -o HelloWorld -f net7.0
  • installed RestSharp into it with dotnet add package RestSharp]
  • ran this script and looked for significant differences between csharp and bash:
#!/usr/bin/env bashset -euxo pipefail
file=Program.cs
mkdir -p fixtures
# for the multipart testsprintf"hello"> hello.txt
forfixturein~/readme/kong-httpsnippet/src/targets/csharp/restsharp/fixtures/*;do
rm -f $file# the custom method isn't supportedif [[ $fixture==*custom-method* ]];thencontinue;fiprintf"using RestSharp;\n\n">$file
sed 's,test/fixtures/files/hello.txt,hello.txt,'"$fixture">>$fileprintf'Console.WriteLine("{0}", response.Content);'>>$file
dotnet run $file>"fixtures/$(basename "$fixture".out)"done## now run the bash fixtures for comparisonforfixturein~/readme/kong-httpsnippet/src/targets/shell/curl/fixtures/*;do# the curl for custom-indentation does not work properly, so we need to add# || true
sed 's,test/fixtures/files/hello.txt,hello.txt,'"$fixture"|
bash >"fixtures/$(basename "$fixture".out)"||truedone# then, compare the outputsforfixturein~/readme/kong-httpsnippet/kong-httpsnippet/src/targets/http/http1.1/fixtures/*;do
base=$(basename "$fixture")
cs="fixtures/$base.cs.out"
sh="fixtures/$base.sh.out"if [[ !-e$cs ]];thenprintf"Unable to find fixture %s\n""$cs";continue;fiif [[ !-e$cs ]];thenprintf"Unable to find fixture %s\n""$sh";continue;fi
git diff "fixtures/$base.cs.out""fixtures/$base.sh.out"||truedone

@llimllib

llimllib commented Jul 10, 2023

Copy link
Copy Markdown
Author

Closing here, fixed in readmeio/httpsnippet, here

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@llimllib