Skip to content

Commit

Permalink
added/renamed/enabled tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mmews committed Feb 16, 2024
1 parent 7a616e4 commit 129082d
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public ProjectDescription loadProjectDescriptionAtLocation(FileURI location, URI
? packageJsonHelper.convertToProjectDescription(packageJSON)
: null;
if (pdbFromPackageJSON != null) {
// note the order is important here:
// the order is important here:

setInformationFromFileSystem(location, pdbFromPackageJSON);
setInformationFromPnpmWorkspace(location, pdbFromPackageJSON);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/**
* Copyright (c) 2020 NumberFour AG.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* NumberFour AG - Initial API and implementation
*/
package org.eclipse.n4js.ide.tests.builder;

import java.util.Map;

import org.eclipse.n4js.ide.tests.helper.server.AbstractIdeTest;
import org.eclipse.n4js.ide.tests.helper.server.TestWorkspaceManager;
import org.eclipse.n4js.workspace.N4JSSourceFolderSnapshotForPackageJson;
import org.eclipse.n4js.workspace.WorkspaceAccess;
import org.eclipse.n4js.xtext.workspace.ProjectConfigSnapshot;
import org.eclipse.n4js.xtext.workspace.SourceFolderSnapshot;
import org.junit.Assert;
import org.junit.Test;

import com.google.common.collect.ImmutableSet;
import com.google.inject.Inject;

/**
* Test if the workspace project does not have the default source folder '.'.
*/

public class WorkspaceNoDefaultSourceFolderPnpmTest extends AbstractIdeTest {

@Inject
WorkspaceAccess workspaceAccess;

private static Map<String, Map<String, String>> testData = Map.of(
"main-project", Map.of(
"MainModule", """
// empty
""",
CFG_DEPENDENCIES, """
library-project-other-name
"""),
"library-project", Map.of(
"LibraryModule", """
// empty
"""));

@Test
public void test() throws Exception {
testWorkspaceManager.createTestOnDisk(testData);

startAndWaitForLspServer();

ProjectConfigSnapshot pc = concurrentIndex.getProjectConfig(TestWorkspaceManager.YARN_TEST_PROJECT);
Assert.assertNotNull(pc);

ImmutableSet<? extends SourceFolderSnapshot> sfs = pc.getSourceFolders();

Assert.assertEquals(1, sfs.size());
Assert.assertTrue(sfs.iterator().next() instanceof N4JSSourceFolderSnapshotForPackageJson);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/**
* Copyright (c) 2020 NumberFour AG.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* NumberFour AG - Initial API and implementation
*/
package org.eclipse.n4js.ide.tests.builder;

import java.nio.file.Path;
import java.util.Map;

import org.eclipse.n4js.ide.tests.helper.server.AbstractIdeTest;
import org.eclipse.n4js.ide.tests.helper.server.TestWorkspaceManager;
import org.eclipse.n4js.utils.URIUtils;
import org.eclipse.n4js.workspace.N4JSSourceFolderSnapshotForPackageJson;
import org.eclipse.n4js.workspace.WorkspaceAccess;
import org.eclipse.n4js.workspace.locations.FileURI;
import org.eclipse.n4js.xtext.workspace.ProjectConfigSnapshot;
import org.eclipse.n4js.xtext.workspace.SourceFolderSnapshot;
import org.eclipse.xtext.xbase.lib.Pair;
import org.junit.Assert;
import org.junit.Test;

import com.google.common.collect.ImmutableSet;
import com.google.inject.Inject;

/**
* Test if the workspace project does not have the default source folder '.'.
*/

public class WorkspaceNoDefaultSourceFolderYarnTest extends AbstractIdeTest {

@Inject
WorkspaceAccess workspaceAccess;

private static Map<String, Map<String, String>> testData = Map.of(
"main-project", Map.of(
"MainModule", """
// empty
""",
CFG_DEPENDENCIES, """
library-project-other-name
"""),
"library-project", Map.of(
"LibraryModule", """
// empty
"""));

@Test
public void test() throws Exception {
testWorkspaceManager.createTestOnDisk(testData);

Path pnpmws = Path.of(getRoot().toString(), TestWorkspaceManager.YARN_TEST_PROJECT, "pnpm-workspace.yaml");
FileURI pnpmwsUri = new FileURI(URIUtils.toFileUri(pnpmws));
createFileOnDiskWithoutNotification(pnpmwsUri, "packages:\n"
+ " - 'packages/*'");

Path pckjws = Path.of(getRoot().toString(), TestWorkspaceManager.YARN_TEST_PROJECT, "package.json");
FileURI pckjUri = new FileURI(URIUtils.toFileUri(pckjws));
changeFileOnDiskWithoutNotification(pckjUri, Pair.of("\"workspaces\"", "\"ignore_me\""));

startAndWaitForLspServer();

ProjectConfigSnapshot pc = concurrentIndex.getProjectConfig(TestWorkspaceManager.YARN_TEST_PROJECT);
Assert.assertNotNull(pc);

ImmutableSet<? extends SourceFolderSnapshot> sfs = pc.getSourceFolders();

Assert.assertEquals(1, sfs.size());
Assert.assertTrue(sfs.iterator().next() instanceof N4JSSourceFolderSnapshotForPackageJson);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* Test two cases of projects with the same project name within a yarn setup
*/

public class YarnDifferentPackageNames extends AbstractIncrementalBuilderTest {
public class YarnDifferentPackageNamesTest extends AbstractIncrementalBuilderTest {

private static Map<String, Map<String, String>> testData = Map.of(
"main-project", Map.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* Test two cases of projects with the same project name within a yarn setup
*/
@SuppressWarnings("unchecked")
public class YarnProjectDuplicateNames extends AbstractIncrementalBuilderTest {
public class YarnProjectDuplicateNamesTest extends AbstractIncrementalBuilderTest {

private static Map<String, Map<String, String>> testData1 = Map.of(
TestWorkspaceManager.YARN_TEST_PROJECT, Map.of(
Expand Down

0 comments on commit 129082d

Please sign in to comment.