Skip to content

Commit

Permalink
Simplify go test case
Browse files Browse the repository at this point in the history
  • Loading branch information
x0k committed Jul 4, 2024
1 parent f3ae41a commit 6a31db8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
12 changes: 6 additions & 6 deletions apps/ppp/src/content/design-patterns/factory/go/code.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package factory
package payment

type PaymentSystemType string
type SystemType int

const (
PayPal PaymentSystemType = "paypal"
WebMoney PaymentSystemType = "webmoney"
CatBank PaymentSystemType = "cat-bank"
PayPal SystemType = iota
WebMoney
CatBank
)

func Payment(tp PaymentSystemType, base int, amount int) int {
func Payment(tp SystemType, base int, amount int) int {
panic("Not implemented")
}
8 changes: 7 additions & 1 deletion apps/ppp/src/content/design-patterns/factory/go/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,20 @@ import type { UniversalFactory } from "testing/actor";
import type { GoUniversalFactoryData } from "@/lib/workers/go";

import type { Input, Output } from "../tests-data";
import type { PaymentSystemType } from "../reference";

export const factory: UniversalFactory<
Input,
Output,
GoUniversalFactoryData<Input, Output>
> = ({ makeTestRunnerFactory }) => {
const GO_PAYMENT_SYSTEM_TYPES: Record<PaymentSystemType, number> = {
paypal: 0,
webmoney: 1,
"cat-bank": 2,
};
return makeTestRunnerFactory(
({ paymentSystem, amount, base }) =>
`factory.Payment(factory.PaymentSystemType("${paymentSystem}"), ${base}, ${amount})`
`payment.Payment(payment.SystemType(${GO_PAYMENT_SYSTEM_TYPES[paymentSystem]}), ${base}, ${amount})`
);
};

0 comments on commit 6a31db8

Please sign in to comment.