aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/cli/internal/inference/inference_test.go
diff options
context:
space:
mode:
author简律纯 <hsiangnianian@outlook.com>2023-04-28 01:36:55 +0800
committer简律纯 <hsiangnianian@outlook.com>2023-04-28 01:36:55 +0800
commitfc8c5fdce62fb229202659408798a7b6c98f6e8b (patch)
tree7554f80e50de4af6fd255afa7c21bcdd58a7af34 /cli/internal/inference/inference_test.go
parentdd84b9d64fb98746a230cd24233ff50a562c39c9 (diff)
downloadHydroRoll-fc8c5fdce62fb229202659408798a7b6c98f6e8b.tar.gz
HydroRoll-fc8c5fdce62fb229202659408798a7b6c98f6e8b.zip
Diffstat (limited to 'cli/internal/inference/inference_test.go')
-rw-r--r--cli/internal/inference/inference_test.go97
1 files changed, 0 insertions, 97 deletions
diff --git a/cli/internal/inference/inference_test.go b/cli/internal/inference/inference_test.go
deleted file mode 100644
index ed82ecc..0000000
--- a/cli/internal/inference/inference_test.go
+++ /dev/null
@@ -1,97 +0,0 @@
-package inference
-
-import (
- "reflect"
- "testing"
-
- "github.com/vercel/turbo/cli/internal/fs"
-)
-
-func getFrameworkBySlug(slug string) *Framework {
- for _, framework := range _frameworks {
- if framework.Slug == slug {
- return &framework
- }
- }
- panic("that framework doesn't exist")
-}
-
-func TestInferFramework(t *testing.T) {
- tests := []struct {
- name string
- pkg *fs.PackageJSON
- want *Framework
- }{
- {
- name: "Hello world",
- pkg: nil,
- want: nil,
- },
- {
- name: "Empty dependencies",
- pkg: &fs.PackageJSON{UnresolvedExternalDeps: map[string]string{}},
- want: nil,
- },
- {
- name: "Finds Blitz",
- pkg: &fs.PackageJSON{UnresolvedExternalDeps: map[string]string{
- "blitz": "*",
- }},
- want: getFrameworkBySlug("blitzjs"),
- },
- {
- name: "Order is preserved (returns blitz, not next)",
- pkg: &fs.PackageJSON{UnresolvedExternalDeps: map[string]string{
- "blitz": "*",
- "next": "*",
- }},
- want: getFrameworkBySlug("blitzjs"),
- },
- {
- name: "Finds next without blitz",
- pkg: &fs.PackageJSON{UnresolvedExternalDeps: map[string]string{
- "next": "*",
- }},
- want: getFrameworkBySlug("nextjs"),
- },
- {
- name: "match strategy of all works (solid)",
- pkg: &fs.PackageJSON{UnresolvedExternalDeps: map[string]string{
- "solid-js": "*",
- "solid-start": "*",
- }},
- want: getFrameworkBySlug("solidstart"),
- },
- {
- name: "match strategy of some works (nuxt)",
- pkg: &fs.PackageJSON{UnresolvedExternalDeps: map[string]string{
- "nuxt3": "*",
- }},
- want: getFrameworkBySlug("nuxtjs"),
- },
- {
- name: "match strategy of some works (c-r-a)",
- pkg: &fs.PackageJSON{UnresolvedExternalDeps: map[string]string{
- "react-scripts": "*",
- }},
- want: getFrameworkBySlug("create-react-app"),
- },
- {
- name: "Finds next in non monorepo",
- pkg: &fs.PackageJSON{
- Dependencies: map[string]string{
- "next": "*",
- },
- Workspaces: []string{},
- },
- want: getFrameworkBySlug("nextjs"),
- },
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- if got := InferFramework(tt.pkg); !reflect.DeepEqual(got, tt.want) {
- t.Errorf("InferFramework() = %v, want %v", got, tt.want)
- }
- })
- }
-}