Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add More Tests #21

Merged
merged 22 commits into from
Nov 1, 2022
Merged

Add More Tests #21

merged 22 commits into from
Nov 1, 2022

Conversation

MahdiBM
Copy link
Collaborator

@MahdiBM MahdiBM commented Oct 14, 2022

Problem

Penny needs better tests so we can put more trust in it to be working after each update.

Some Explanation

I don't intend to add a lot of tests in this PR.
What I want to do is to prepare the abstractions and clear up the way.
Then anybody will be able to write some tests without a need to worry about more complex stuff.

@MahdiBM MahdiBM marked this pull request as draft October 14, 2022 12:45
@MahdiBM
Copy link
Collaborator Author

MahdiBM commented Oct 16, 2022

Swift nightly tests seem to fail due to one of the usual sendable changes.

@0xTim feel free to let me know if any improvements can be done.

@MahdiBM MahdiBM requested a review from 0xTim October 16, 2022 10:24
@MahdiBM MahdiBM marked this pull request as ready for review October 16, 2022 11:06
Copy link
Member

@0xTim 0xTim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments but no blockers, great work!

import Logging
import Foundation

public class FakeAWSHTTPClient: AWSHTTPClient {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this protocol disappearing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

o hmm, I don't follow AWS SDKs closely, but I can see that they're removing it: soto-project/soto-core@addcfe6

I think we might need to make a "AWSClientProtocol" of ourselves now?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oo the thing is we're still using soto 5 instead of the newest soto 6 ... that's why they are removing the protocol (since it no longer has any use in soto 6)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can update Soto in a separate PR. Where are you abstracting the AWSClient? (I'm on mobile). We probably want to move the abstraction a layer up rather to eg a EC2Interface rather than the client directly. That will make it easier to migrate Soto versions too

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So that'll be a "AWSClientProtocol" of ourselves again? This way we can hide the AWS interface under a protocol of ourselves and only add functions we need (which makes updating easier too)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry it appears Github doesn't update the conversation unless you refresh the page, so i missed your last comment.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replying to your last comment:
Yeah i was thinking of that too a while ago (although i forgot about it later)... i'll see what i can do

Copy link
Collaborator Author

@MahdiBM MahdiBM Nov 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just pushed the changes.
I didn't find a better solution than the underlyingHandler solution.
We can simplify these after we update our soto stuff, including the runtime.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok i just noticed something ... let me check ...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushed some more changes to simplify those stuff

CODE/Tests/Fake/FakeManager.swift Outdated Show resolved Hide resolved
@MahdiBM
Copy link
Collaborator Author

MahdiBM commented Nov 1, 2022

Its interesting that the tests randomly throw

note: module 'PennyBOT' is the main module of an executable, and cannot be imported by tests and other targets

once in a while, even in Swift 5.6 (other than nightly) ... this doesn't happen at all on macOS
I'll check to see if something can be done ... I've seen some other weird test failures with swift 5.6 too ...

@0xTim
Copy link
Member

0xTim commented Nov 1, 2022

Why not just drop 5.6 and move to 5.7?

@MahdiBM
Copy link
Collaborator Author

MahdiBM commented Nov 1, 2022

we definitely should 😅
should i do it? i can update the main branch and merge this pr with main so we can test the pr with 5.7

@0xTim
Copy link
Member

0xTim commented Nov 1, 2022

Yep sounds good

@MahdiBM
Copy link
Collaborator Author

MahdiBM commented Nov 1, 2022

All ready!

Copy link
Member

@0xTim 0xTim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One last comment then good to go

}
}

private struct FakeDiscordClient: DiscordClient {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to split these out into their own types

Copy link
Collaborator Author

@MahdiBM MahdiBM Nov 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume you mean the send and sendAndAwaitResponse functions?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I meant files - FakeDiscordClient and FakeResponseStorage should probably live in their own files

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea :)

@MahdiBM MahdiBM requested a review from 0xTim November 1, 2022 17:26
@MahdiBM MahdiBM merged commit 63ae572 into vapor:main Nov 1, 2022
This was referenced Nov 1, 2022
@MahdiBM MahdiBM deleted the mahdibm-tests branch November 1, 2022 20:37
Sign up for free to 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.

2 participants