Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: Refactor API routes to use UUIDs instead of friendly names #401

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

Merged
merged 24 commits into from
Mar 7, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix e2e tests
  • Loading branch information
kylecarbs committed Mar 7, 2022
commit 74e8f43b44c1683295b3e3e663380996b3dcf93d
2 changes: 2 additions & 0 deletions .github/workflows/coder.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ jobs:
GOMAXPROCS: ${{ runner.os == 'Windows' && 1 || 2 }}
run: gotestsum --junitfile="gotests.xml" --packages="./..." --
-covermode=atomic -coverprofile="gotests.coverage"
-coverpkg=./.,github.com/coder/coder/codersdk
-timeout=3m -count=$GOCOUNT -race -short -failfast

- name: Upload DataDog Trace
Expand All @@ -172,6 +173,7 @@ jobs:
if: runner.os == 'Linux'
run: DB=true gotestsum --junitfile="gotests.xml" --packages="./..." --
-covermode=atomic -coverprofile="gotests.coverage" -timeout=3m
-coverpkg=./.,github.com/coder/coder/codersdk
-count=1 -race -parallel=2 -failfast

- name: Upload DataDog Trace
Expand Down
34 changes: 34 additions & 0 deletions coderd/provisionerjobs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,38 @@ func TestProvisionerJobLogs(t *testing.T) {
_, ok := <-logs
require.False(t, ok)
})

t.Run("List", func(t *testing.T) {
t.Parallel()
client := coderdtest.New(t, nil)
user := coderdtest.CreateFirstUser(t, client)
coderdtest.NewProvisionerDaemon(t, client)
version := coderdtest.CreateProjectVersion(t, client, user.OrganizationID, &echo.Responses{
Parse: echo.ParseComplete,
Provision: []*proto.Provision_Response{{
Type: &proto.Provision_Response_Log{
Log: &proto.Log{
Level: proto.LogLevel_INFO,
Output: "log-output",
},
},
}, {
Type: &proto.Provision_Response_Complete{
Complete: &proto.Provision_Complete{},
},
}},
})
project := coderdtest.CreateProject(t, client, user.OrganizationID, version.ID)
coderdtest.AwaitProjectVersionJob(t, client, version.ID)
workspace := coderdtest.CreateWorkspace(t, client, "me", project.ID)
build, err := client.CreateWorkspaceBuild(context.Background(), workspace.ID, coderd.CreateWorkspaceBuildRequest{
ProjectVersionID: project.ActiveVersionID,
Transition: database.WorkspaceTransitionStart,
})
require.NoError(t, err)
coderdtest.AwaitWorkspaceBuildJob(t, client, build.ID)
logs, err := client.WorkspaceBuildLogsBefore(context.Background(), build.ID, time.Now())
require.NoError(t, err)
require.Len(t, logs, 1)
})
}
2 changes: 1 addition & 1 deletion develop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function create_initial_user() {
curl -X POST \
-d "{\"email\": \"$EMAIL\", \"username\": \"$USERNAME\", \"organization\": \"$ORGANIZATION\", \"password\": \"$PASSWORD\"}" \
-H 'Content-Type:application/json' \
http://localhost:3000/api/v2/user
http://localhost:3000/api/v2/users/first
}

# Run yarn install, to make sure node_modules are ready to go
Expand Down
2 changes: 1 addition & 1 deletion images/coder/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function create_initial_user() {
curl -X POST \
-d '{"email": "'"$EMAIL"'", "username": "'"$USERNAME"'", "organization": "'"$ORGANIZATION"'", "password": "'"$PASSWORD"'"}' \
-H 'Content-Type:application/json' \
"http://localhost:$PORT/api/v2/user"
"http://localhost:$PORT/api/v2/users/first"
}

# This is a way to run multiple processes in parallel, and have Ctrl-C work correctly
Expand Down
2 changes: 1 addition & 1 deletion site/e2e/globalSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const globalSetup = async (config: FullConfig): Promise<void> => {
})

// Create initial user
await context.post("/api/v2/user", {
await context.post("/api/v2/users/first", {
data: {
email,
username,
Expand Down
4 changes: 3 additions & 1 deletion site/pages/projects/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ import { CodeExample } from "../../components/CodeExample/CodeExample"
const ProjectsPage: React.FC = () => {
const styles = useStyles()
const { me, signOut } = useUser(true)
const { data: projects, error } = useSWR<Project[] | null, Error>("/api/v2/projects")
const { data: orgs, error: orgsError } = useSWR<Organization[], Error>("/api/v2/users/me/organizations")
const { data: projects, error } = useSWR<Project[] | null, Error>(
orgs ? `/api/v2/organizations/${orgs[0].id}/projects` : null,
)

if (error) {
return <ErrorSummary error={error} />
Expand Down