(t *testing.T)
| 677 | } |
| 678 | |
| 679 | func TestAutoCreate(t *testing.T) { |
| 680 | if testing.Short() { |
| 681 | t.SkipNow() |
| 682 | return |
| 683 | } |
| 684 | disableAutoCreate := func(conf *config.Config) { |
| 685 | conf.Room.AutoCreate = false |
| 686 | } |
| 687 | t.Run("cannot join if room isn't created", func(t *testing.T) { |
| 688 | s := createSingleNodeServer(disableAutoCreate) |
| 689 | go func() { |
| 690 | if err := s.Start(); err != nil { |
| 691 | logger.Errorw("server returned error", err) |
| 692 | } |
| 693 | }() |
| 694 | defer s.Stop(true) |
| 695 | |
| 696 | waitForServerToStart(s) |
| 697 | |
| 698 | for _, testRTCServicePath := range testRTCServicePaths { |
| 699 | t.Run(fmt.Sprintf("testRTCServicePath=%s", testRTCServicePath.String()), func(t *testing.T) { |
| 700 | token := joinToken(testRoom, "start-before-create", nil) |
| 701 | opts := &testclient.Options{} |
| 702 | testRTCServicePathToTestClientOptions(testRTCServicePath, opts) |
| 703 | _, err := testclient.NewWebSocketConn( |
| 704 | fmt.Sprintf("ws://localhost:%d", defaultServerPort), |
| 705 | token, |
| 706 | opts, |
| 707 | ) |
| 708 | require.Error(t, err) |
| 709 | |
| 710 | // second join should also fail |
| 711 | token = joinToken(testRoom, "start-before-create-2", nil) |
| 712 | _, err = testclient.NewWebSocketConn( |
| 713 | fmt.Sprintf("ws://localhost:%d", defaultServerPort), |
| 714 | token, |
| 715 | opts, |
| 716 | ) |
| 717 | require.Error(t, err) |
| 718 | }) |
| 719 | } |
| 720 | }) |
| 721 | |
| 722 | t.Run("join with explicit createRoom", func(t *testing.T) { |
| 723 | s := createSingleNodeServer(disableAutoCreate) |
| 724 | go func() { |
| 725 | if err := s.Start(); err != nil { |
| 726 | logger.Errorw("server returned error", err) |
| 727 | } |
| 728 | }() |
| 729 | defer s.Stop(true) |
| 730 | |
| 731 | waitForServerToStart(s) |
| 732 | |
| 733 | // explicitly create |
| 734 | _, err := roomClient.CreateRoom(contextWithToken(createRoomToken()), &livekit.CreateRoomRequest{Name: testRoom}) |
| 735 | require.NoError(t, err) |
| 736 |
nothing calls this directly
no test coverage detected